xml.ElementInformationItem¶
The xml.ElementInformationItem class represents an XML element and exposes the properties of the
Element Information Item as well as the properties
of the post-schema-validation infoset for elements.
There is an xml.ElementInformationItem for each element appearing in the XML document. One of the xml.ElementInformationItem objects
is the value of the xml.DocumentInformationItem.document_element property, corresponding to the root of the element tree,
and all other xml.ElementInformationItem objects are accessible by recursively following the xml.ElementInformationItem.children property.
Base class: xml.InformationItem
-
class
xml.ElementInformationItem¶ Proper instances of this class will be created within RaptorXML only, instantiation from script code will throw a
NotImplementedErrorexception.
Attributes¶
-
xml.ElementInformationItem.attributes¶ Returns an iterator of
xml.AttributeInformationItemobjects, specified or defaulted from the DTD, of this element. Namespace declarations are not provided by this iterator.
-
xml.ElementInformationItem.base_uri¶ Returns the base URI of the element.
-
xml.ElementInformationItem.children¶ Returns an iterator of child
xml.InformationItemobjects, in document order.This provides
one
xml.ElementInformationItemfor each element,one
xml.ProcessingInstructionInformationItemfor each processing instruction,one
xml.UnexpandedEntityReferenceInformationItemfor each unprocessed external entity,one
xml.CharDataInformationItemfor each block of text andone
xml.CommentInformationItemfor each comment
appearing immediately within the current element.
-
xml.InformationItem.document Returns an
xml.Documentobject representing the XML instance file containing this information item.
-
xml.ElementInformationItem.element_attribution¶ [PSVI] During validation
xml.ElementInformationItemobjects are associated withxsd.Particleorxsd.OpenContentschema components. This property returns that component or None if no validation was attempted.
-
xml.ElementInformationItem.element_declaration¶ [PSVI] Returns the governing
xsd.ElementDeclarationof thisxml.ElementInformationItemor None if no such declaration is known.
-
xml.ElementInformationItem.first_attribute¶ Returns an
xml.AttributeInformationItemobject representing the first attribute in document order. Returns None if this element does not have any attributes.
-
xml.InformationItem.first_child Returns an
xml.InformationItemobject representing the first child information item. Returns None if this information item does not have any children.
-
xml.ElementInformationItem.first_child_element¶ Returns an
xml.ElementInformationItemobject representing the first child element in document order. Returns None if this element does not have any child elements.
-
xml.ElementInformationItem.first_namespace_attribute¶ Returns an
xml.NSAttributeInformationItemobject representing the first namespace attribute in document order. Returns None if this element does not have any namespace attributes.
-
xml.ElementInformationItem.in_scope_namespaces¶ Returns a dictionary from prefix to namespace name, with one entry for each of the namespaces in effect for this element.
This dictionary always contains an entry with the prefix ‘xml’ which is implicitly bound to the namespace name ‘http://www.w3.org/XML/1998/namespace’. It does not contain an item with the prefix ‘xmlns’ (used for declaring namespaces), since an application can never encounter an element or attribute with that prefix.
The dictionary will include namespace items corresponding to all of the members of namespace_attributes, except for any representing declarations of the form xmlns=”” or xmlns:name=””, which do not declare a namespace, but rather undeclare the default namespace and prefixes.
When resolving the prefixes of qualified names this property or the find_in_scope_namespace method should be used in preference to the namespace_attributes property.
-
xml.ElementInformationItem.inherited_attributes¶ [PSVI] Returns an iterator of inherited
xml.AttributeInformationItemobjects of this element.
-
xml.ElementInformationItem.line_number¶ Returns an int indicating the line number in the XML document that contains this element.
-
xml.ElementInformationItem.local_name¶ Returns the local part of the element name. This does not include any namespace prefix or following colon.
-
xml.ElementInformationItem.member_type_definition¶ [PSVI] Returns the validating
xsd.SimpleTypeDefinitionof the schema_actual_value, or None if the governingxsd.SimpleTypeDefinitionhas variety !=xsd.SimpleTypeVariety.UNION.
-
xml.ElementInformationItem.namespace_attributes¶ Returns an iterator of namespace declaration
xml.NSAttributeInformationItemobjects (specified or defaulted from the DTD) of this element. Declarations of the form xmlns=”” and xmlns:name=””, which undeclare the default namespace and prefixes respectively, count as namespace declarations.Prefix undeclaration was added in Namespaces in XML 1.1. By definition, all namespace attributes (including those named ‘xmlns’, whose prefix attribute has no value) have a namespace URI of ‘http://www.w3.org/2000/xmlns/’.
-
xml.ElementInformationItem.namespace_name¶ Returns the namespace name, if any, of the element. If the element does not belong to a namespace, this property returns None.
-
xml.InformationItem.next Returns an
xml.InformationItemobject representing the next sibling information item. Returns None if there is no next sibling information item.
-
xml.ElementInformationItem.next_element¶ Returns an
xml.ElementInformationItemobject representing the next sibling element in document order. Returns None if this is the last element.
-
xml.ElementInformationItem.nil¶ [PSVI] Returns True if clause 3.2.3 of Element Locally Valid is satisfied, otherwise False.
-
xml.ElementInformationItem.parent¶ Returns the
xml.DocumentInformationItemorxml.ElementInformationItemwhich contains thisxml.InformationItemin its children property.
-
xml.ElementInformationItem.parent_document¶ Returns the
xml.DocumentInformationItemwhich indirectly contains thisxml.InformationItemin its children property.
-
xml.ElementInformationItem.prefix¶ Returns the namespace prefix part of the element name. If the name is unprefixed, this attribute is None.
-
xml.InformationItem.prev Returns an
xml.InformationItemobject representing the previous sibling information item. Returns None if there is no previous sibling information item.
-
xml.ElementInformationItem.prev_element¶ Returns an
xml.ElementInformationItemobject representing the previous sibling element in document order. Returns None if this is the first element.
-
xml.ElementInformationItem.qname¶ Returns an
xml.QNameobject representing the expended name of the XML element.
-
xml.ElementInformationItem.schema_actual_value¶ [PSVI] Returns the actual value as a subclass of xsd.AnySimpleType corresponding to the schema_normalized_value property or None if schema_normalized_value property is absent.
-
xml.ElementInformationItem.schema_normalized_value¶ [PSVI] If nil is False and either the governing_type_definition is a
xsd.SimpleTypeDefinitionor its content type has varietyxsd.ContentTypeVariety.SIMPLE, then it returns the normalized value of the item as validated (or in case of an appliedxsd.ValueConstraint, the lexical form of thisxsd.ValueConstraint). Otherwise it returns None.
-
xml.ElementInformationItem.schema_specified¶ [PSVI] Returns the schema specified property of the
xml.ElementInformationItem.Possible values are:
xml.SchemaSpecified.NONEif no schema validity was assessed for this element.xml.SchemaSpecified.INFOSETif the value of thexml.ElementInformationItemoriginates in the infoset (instance).xml.SchemaSpecified.SCHEMAif the value of thexml.ElementInformationItemoriginates in a value constraint in the schema.
-
xml.ElementInformationItem.source_element¶ Returns the source
xml.ElementInformationItemin case that the Infoset was constructed by an Inline XBRL transformation.
-
xml.ElementInformationItem.type_definition¶ [PSVI] Returns the governing type definition of this
xml.ElementInformationItemor None if no such definition is known.
-
xml.ElementInformationItem.validation_attempted¶ [PSVI] Returns the validation attempted state of the
xml.ElementInformationItem.Possible values are:
xml.ValidationAttempted.FULLif thexml.ElementInformationItemand all its descendants and attributes were strictly assessed.xml.ValidationAttempted.NONEif neither thexml.ElementInformationItemnor any of its descendants and attributes were strictly assessed.xml.ValidationAttempted.PARTIALotherwise.
-
xml.ElementInformationItem.validity¶ [PSVI] Returns the schema-validity of the
xml.ElementInformationItem.Possible values are:
xml.Validity.VALIDif thexml.ElementInformationItemwas strictly assessed and is valid.xml.Validity.INVALIDif thexml.ElementInformationItemwas strictly assessed and it is invalid.xml.Validity.NOTKNOWNif thexml.ElementInformationItemobjects was not strictly assessed.
Methods¶
-
xml.ElementInformationItem.element_children(name=None)¶ Returns an iterator of child
xml.ElementInformationItemobjects, in document order. If name is not None, the iterator will return only childxml.ElementInformationItemobjects with the given name.
-
xml.ElementInformationItem.find_attribute(name)¶ Returns the
xml.AttributeInformationItemwith the given name. Name may be either axml.QName, a local name or a tuple of local name and namespace name. If no such attribute exists, the method returns None.
-
xml.ElementInformationItem.find_child_element(name)¶ Returns the first child
xml.ElementInformationItemwith the given name. Name may be either axml.QName, a local name or a tuple of local name and namespace name. If no such element exists, the method returns None.
-
xml.ElementInformationItem.find_in_scope_namespace(prefix)¶ Returns the in-scope namespace for prefix. If prefix is not bound to a namespace in the scope of this
xml.ElementInformationItemthe method returns None.
-
xml.ElementInformationItem.is_empty()¶ Returns an True if element is empty (does not have any child information items).
-
xml.ElementInformationItem.serialize(pretty_print=True, omit_start_tag=False, add_unspecified_attributes=False, add_missing_namespace_bindings=False, namespace_bindings=None)¶ Returns a string with the serialized XML element. Setting the option pretty_print will insert appropriate indendation and newlines after each XML element. Setting the option omit_start_tag will serialize only this element’s child informaiton item. Setting the option add_unspecified_attributes will add any missing attributes that have a default value in the DTD/XSD Schema. Setting the option add_missing_namespace_bindings will ensure that all referenced namespace bindings in the parent hierarchy are copied to this element.
-
xml.ElementInformationItem.text_content()¶ Returns a string containing the concatenated values of the child
xml.CharDataInformationItemobjects.
-
xml.InformationItem.xlocation_url(item_value=False) Returns proprietary Altova URL to this Item. If item_value is True the URL references the value content of an Element or Attribute item (is ignored for other kinds).
-
xml.ElementInformationItem.xpath()¶ Returns an XPath to this
xml.ElementInformationItemin the form “/*[1]/*[4]/…”. The runtime of this method is in O(d) if element position infos are cached on thexml.DocumentInformationItem(seexml.DocumentInformationItem.build_element_position_cache()) and in O(n) otherwise (d is the depth of thexml.ElementInformationItemand n is the number ofxml.ElementInformationItemobjects in the document). If you need the XPaths for many elements/attributes invokexml.DocumentInformationItem.build_element_position_cache()first.
-
xml.ElementInformationItem.xpointer(with_document_uri=False, force_element_scheme=False)¶ Returns an XPointer to this
xml.ElementInformationItem. If with_document_uri is True an URI in the form “scheme://document_base_URI#xpointer” is returned, otherwise only the XPointer fragment. If force_element_scheme is True no shorthand pointers are returned.The runtime of this method is in O(d) if element position infos are cached on the
xml.DocumentInformationItem(seexml.DocumentInformationItem.build_element_position_cache()) and in O(n) otherwise (d is the depth of thexml.ElementInformationItemand n is the number ofxml.ElementInformationItemobjects in the document). If you need the XPointers for many elements invokexml.DocumentInformationItem.build_element_position_cache()first.
Special methods¶
__bool__, __eq__, __ge__, __gt__, __le__, __lt__, __ne__