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 NotImplementedError exception.

Attributes

xml.ElementInformationItem.attributes

Returns an iterator of xml.AttributeInformationItem objects, 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.InformationItem objects, in document order.

This provides

appearing immediately within the current element.

xml.InformationItem.document

Returns an xml.Document object representing the XML instance file containing this information item.

xml.ElementInformationItem.element_attribution

[PSVI] During validation xml.ElementInformationItem objects are associated with xsd.Particle or xsd.OpenContent schema components. This property returns that component or None if no validation was attempted.

xml.ElementInformationItem.element_declaration

[PSVI] Returns the governing xsd.ElementDeclaration of this xml.ElementInformationItem or None if no such declaration is known.

xml.ElementInformationItem.first_attribute

Returns an xml.AttributeInformationItem object representing the first attribute in document order. Returns None if this element does not have any attributes.

xml.InformationItem.first_child

Returns an xml.InformationItem object 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.ElementInformationItem object 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.NSAttributeInformationItem object 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.AttributeInformationItem objects 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.SimpleTypeDefinition of the schema_actual_value, or None if the governing xsd.SimpleTypeDefinition has variety != xsd.SimpleTypeVariety.UNION.

xml.ElementInformationItem.namespace_attributes

Returns an iterator of namespace declaration xml.NSAttributeInformationItem objects (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.InformationItem object representing the next sibling information item. Returns None if there is no next sibling information item.

xml.ElementInformationItem.next_element

Returns an xml.ElementInformationItem object 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.DocumentInformationItem or xml.ElementInformationItem which contains this xml.InformationItem in its children property.

xml.ElementInformationItem.parent_document

Returns the xml.DocumentInformationItem which indirectly contains this xml.InformationItem in 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.InformationItem object representing the previous sibling information item. Returns None if there is no previous sibling information item.

xml.ElementInformationItem.prev_element

Returns an xml.ElementInformationItem object representing the previous sibling element in document order. Returns None if this is the first element.

xml.ElementInformationItem.qname

Returns an xml.QName object 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.SimpleTypeDefinition or its content type has variety xsd.ContentTypeVariety.SIMPLE, then it returns the normalized value of the item as validated (or in case of an applied xsd.ValueConstraint, the lexical form of this xsd.ValueConstraint). Otherwise it returns None.

xml.ElementInformationItem.schema_specified

[PSVI] Returns the schema specified property of the xml.ElementInformationItem.

Possible values are:

  • xml.SchemaSpecified.NONE if no schema validity was assessed for this element.

  • xml.SchemaSpecified.INFOSET if the value of the xml.ElementInformationItem originates in the infoset (instance).

  • xml.SchemaSpecified.SCHEMA if the value of the xml.ElementInformationItem originates in a value constraint in the schema.

xml.ElementInformationItem.source_element

Returns the source xml.ElementInformationItem in case that the Infoset was constructed by an Inline XBRL transformation.

xml.ElementInformationItem.type_definition

[PSVI] Returns the governing type definition of this xml.ElementInformationItem or 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.FULL if the xml.ElementInformationItem and all its descendants and attributes were strictly assessed.

  • xml.ValidationAttempted.NONE if neither the xml.ElementInformationItem nor any of its descendants and attributes were strictly assessed.

  • xml.ValidationAttempted.PARTIAL otherwise.

xml.ElementInformationItem.validity

[PSVI] Returns the schema-validity of the xml.ElementInformationItem.

Possible values are:

Methods

xml.ElementInformationItem.element_children(name=None)

Returns an iterator of child xml.ElementInformationItem objects, in document order. If name is not None, the iterator will return only child xml.ElementInformationItem objects with the given name.

xml.ElementInformationItem.find_attribute(name)

Returns the xml.AttributeInformationItem with the given name. Name may be either a xml.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.ElementInformationItem with the given name. Name may be either a xml.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.ElementInformationItem the 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.CharDataInformationItem objects.

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.ElementInformationItem in the form “/*[1]/*[4]/…”. The runtime of this method is in O(d) if element position infos are cached on the xml.DocumentInformationItem (see xml.DocumentInformationItem.build_element_position_cache()) and in O(n) otherwise (d is the depth of the xml.ElementInformationItem and n is the number of xml.ElementInformationItem objects in the document). If you need the XPaths for many elements/attributes invoke xml.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 (see xml.DocumentInformationItem.build_element_position_cache()) and in O(n) otherwise (d is the depth of the xml.ElementInformationItem and n is the number of xml.ElementInformationItem objects in the document). If you need the XPointers for many elements invoke xml.DocumentInformationItem.build_element_position_cache() first.

Special methods

__bool__, __eq__, __ge__, __gt__, __le__, __lt__, __ne__