Class Element
source code
object --+
|
Element
- Known Subclasses:
-
- web.vosi.AVL.AVLElement
- , web.vosi.CAP.CAPElement
- , registry.model.DC.DCElement
- , registry.model.DOC.DOCElement
- , registry.model.OAIDC.OAIDCElement
- , registry.model.OAI.OAIElement
- , protocols.tap.Plan.PlanElement
- , registry.model.RI.RIElement
- , registry.model.SCS.SCSElement
- , registry.model.SIA.SIAElement
- , registry.model.SLAP.SLAPElement
- , web.wsdl.SOAP.SOAPElement
- , registry.model.SSAP.SSAElement
- , stc.stcx.STC.STCElement
- , registry.model.TR.TRElement
- , protocols.uwsactions.UWS.UWSElement
- , registry.model.VOG.VOGElement
- , registry.model.VOR.VORElement
- , registry.model.VS.VSElement
- , registry.model.VSTD.VSTDElement
- , web.vosi.VTM.VTMElement
- , web.wsdl.WSDL.WSDLElement
- , web.wsdl.XSD.XSDElement
- , votable.model._VODMLElements._VODMLElement
- , votable.model.VOTable._VOTElement
An element for serialization into XML.
This is loosely modelled after nevow stan.
Don't add to the children attribute directly, use addChild or (more
usually) __getitem__.
Elements have attributes and children. The attributes are defined,
complete with defaults, in _a_<name> attributes as in AutoNodes.
Attributes are checked.
Children are not usually checked, but you can set a _childSequence
attribute containing a list of (unqualified) element names. These
children will be emitted in the sequence given.
When deriving from Elements, you may need attribute names that are not
python identifiers (e.g., with dashes in them). In that case, define an
attribute _name_a_<att> and point it to any string you want as the
attribute.
When serializing these, empty elements (i.e. those having an empty
text and having no non-empty children) are usually discarded. If you
need such an element (e.g., for attributes), set mayBeEmpty to True.
Since insane XSD mandates that local elements must not be qualified
when elementFormDefault is unqualified, you need to set _local=True on
such local elements to suppress the namespace prefix. Attribute names
are never qualified here. If you need qualified attributes, you'll have
to use attribute name translation.
The content of the DOM may be anything recognized by addChild. In
particular, you can give objects a serializeToXMLStan method returning
strings or an Element to make them good DOM citizens.
Elements cannot harbor mixed content (or rather, there is only one
piece of text).
|
|
|
|
|
|
|
|
|
|
|
deepcopy(self)
returns a deep copy of self. |
source code
|
|
|
|
|
isEmpty(self)
returns true if the current node has no non-empty children and no
non-whitespace text content. |
source code
|
|
|
|
|
|
|
addAttribute(self,
attName,
attValue)
adds attName, attValue to this Element's attributes when
instanciated. |
source code
|
|
|
iterChildrenOfType(self,
type)
iterates over all children having type. |
source code
|
|
|
|
|
|
|
|
|
|
|
asETree(self,
prefixForEmpty=None)
returns an ElementTree instance for the tree below this node. |
source code
|
|
|
render(self,
prefixForEmpty=None,
includeSchemaLocation=True)
returns this and its children as a string. |
source code
|
|
|
__init__(self,
id=None)
x.__init__(...) initializes x; see help(type(x)) for signature |
source code
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
Inherited from object :
__class__
|
adds child to the list of children.
Child may be an Element, a string, or a list or tuple of Elements and
strings. Finally, child may be None, in which case nothing will be
added.
|
returns true if the current node should be part of an output.
That is true if it is either non-empty or _mayBeEmpty is true. An
empty element is one that has only empty children and no non-whitespace
text content.
|
iterates over the defined attribute names of this node.
Each element returned is a pair of the node attribute name and the xml
name (which may be translated via _a_name_<att>
|
adds attName, attValue to this Element's attributes when
instanciated.
You cannot add _a_<attname> attributes to instances. Thus, when
in a pinch, use this.
|
iterates over children whose element name is elName.
This always does a linear search through the children and hence may be
slow.
|
calls func(node, text, attrs, childIter).
This is a building block for tree traversals; the expectation is that
func does something like func(node, text, attrDict, childSequence).
|
returns an ElementTree instance for the tree below this node.
Deprecated. Use Serializer rather than ElementTree.
|
x.__init__(...) initializes x; see help(type(x)) for signature
- Overrides:
object.__init__
- (inherited documentation)
|