music21.musicxml.xmlHandler¶
Converts musicxml xml text to the intermediate mxObjects format.
Document¶
-
class
music21.musicxml.xmlHandler.
Document
¶ Represent a MusicXML document, importing and writing
Document
methods
-
Document.
getBestTitle
()¶ title may be stored in more than one place
-
Document.
open
(fp, audit=False)¶
-
Document.
openPickle
(fp)¶
-
Document.
read
(xmlString, audit=False)¶ Load MusicXML from a string, instead of from a file.
-
Document.
repr
()¶
-
Document.
reprTest
()¶ Basic display for testing
-
Document.
write
(fp)¶
-
Document.
writePickle
(fp)¶
Handler¶
-
class
music21.musicxml.xmlHandler.
Handler
(tagLib=None)¶ The SAX handler reads the MusicXML file and builds a corresponding MusicXMLElement object structure.
this is the main conversion handler for musicxml to mxObjects
Handler
methods
-
Handler.
characters
(charData)¶ Because each _Handler sub-class defines its own _tags, and because each Tag knows whether it is to receive character data or not, this method can be found in the base-class and need not be defined for each sub-class.
-
Handler.
endElement
(name)¶ This handler method builds up the nested MusicXMLElement objects. For simple entities, the charData or attributes might be assigned directly to the attribute of another MusicXMLElement. In other cases, the MusicXMLElement object stored (in the _mxObjs dict) is assigned to another MusicXMLElement.
After assigning the MusicXMLElement to wherever it resides, the storage location (the _mxObjs dict) must be set to None.
-
Handler.
getContent
()¶
-
Handler.
setDocumentLocator
(locator)¶ A locator object can be used to get line numbers from the XML document.
-
Handler.
startElement
(name, attrs)¶ This handler method, in general, simply creates the appropriate MusicXMLElement object and stores it (in the _mxObjs dict). Attributes are loaded if necessary. For a few entities (note, measure) addtional special handling is necessary.