An object base-class for creating and editing specialized XML structures as object representations. Used by the musicxml converter, obviously, but also by environment.py.
>>> a = xmlnode.XMLNode() >>> a.set('charData', 'test')
Attributes without Documentation: charData
Get a data attribute from this XMLNode. If available in the attribute dictionary, return this first.
If available as an object attribute, return this second.
- >>> a = xmlnode.XMLNode() >>> a.hasAttrs() False >>> a = musicxml.Pitch() >>> a.hasAttrs() False >>> a = musicxml.Beam() >>> a.hasAttrs() True
Given a SAX attrs object, load all atributes that are named within this object’s _attr dictionary.
- merge(other, favorSelf=True, returnDeepcopy=True)¶
Given another similar or commonly used XMLNode object, combine all attributes and return a new object.>>> a = xmlnode.XMLNode() >>> a.set('charData', 'green') >>> b = xmlnode.XMLNode() >>> c = b.merge(a) >>> c.get('charData') 'green'
- set(name, value)¶
Set an attribute, using either the name of the attribute, a name that can be converter, or a direct attribute on the object.
provide defaults for all necessary attributes at this level
- toxml(doc=None, parent=None, stringOut=False)¶
Provides XML output as either a text string or as DOM node. This method can be called recursively to build up nodes on a DOM tree. This method will assume that if an self.charData attribute has been defined this is a text element for this node. Attributes, sub entities, and sub nodes are obtained via subclassed method calls.
Shortcut method to provide quick xml out.
Inherits from: XMLNode
To understand what a XMLNodeList is, we need to first see that Nodes are simply xml-like containers. Though many xml-like containers store just character data, like:
Other xml-like containers are really more like lists, not storing character data but other xml-like containers in order, like:
<attributes> <divisions>1</divisions> <key> <fifths>0</fifths> <mode>major</mode> </key> <time symbol="common"> <beats>4</beats> <beat-type>4</beat-type> </time> <clef> <sign>G</sign> <line>2</line> </clef> </attributes>
In these cases, its much easier to have an xml-like container that is list like. That way they can be iterated over or appended to. Thus, NodeLists, which are nodes that give us list-like functionality for the cases where we need them.
Attributes without Documentation: componentList
Attributes inherited from XMLNode: charData