class xsdata.formats.dataclass.parsers.nodes.ElementNode(meta, attrs, ns_map, config, context, position, mixed=False, derived_factory=None, xsi_type=None, xsi_nil=None)[source]#

XmlNode for complex elements and dataclasses.

  • meta (XmlMeta) – Model xml metadata

  • attrs (Dict) – Key-value attribute mapping

  • ns_map (Dict) – Namespace prefix-URI map

  • config (ParserConfig) – Parser configuration

  • context (XmlContext) – Model context provider

  • position (int) – The node position of objects cache

  • mixed (bool) – The node supports mixed content

  • derived_factory (Optional[Type]) – Derived element factory

  • xsi_type (Optional[str]) – The xml type substitution

  • xsi_nil (Optional[bool]) – The xml type substitution

bind(qname, text, tail, objects)[source]#

Build the object tree for the ending element and return whether the result was successful or not.

This entry point is called when an xml element ends and is responsible to parse the current element attributes/text, bind any children objects and initialize new object.

  • qname (str) – Qualified name

  • text (Optional[str]) – Text content

  • tail (Optional[str]) – Tail content

  • objects (List) – The list of intermediate parsed objects, eg [(qname, object)]

Return type:



Parse the given element’s attributes and any text content and return a dictionary of field names and values based on the given class metadata.

bind_objects(params, objects)[source]#

Return a dictionary of qualified object names and their values for the given queue item.

classmethod bind_var(params, var, value)[source]#

Add the given value to the params dictionary with the var name as key.

Wrap the value to a list if var is a list. If the var name already exists it means we have a name conflict and the parser needs to lookup for any available wildcard fields.

Return type:



Whether the binding process was successful or not.

bind_wild_var(params, var, qname, value)[source]#

Add the given value to the params dictionary with the wildcard var name as key.

If the key is already present wrap the previous value into a generic AnyElement instance. If the previous value is already a generic instance add the current value as a child object.

Return type:


bind_mixed_objects(params, var, objects)[source]#

Return a dictionary of qualified object names and their values for the given mixed content xml var.

prepare_generic_value(qname, value)[source]#

Prepare parsed value before binding to a wildcard field.

Return type:


bind_text(params, text)[source]#

Add the given element’s text content if any to the params dictionary with the text var name as key.

Return if any data was bound.

Return type:


bind_wild_text(params, var, txt, tail)[source]#

Extract the text and tail content and bind it accordingly in the params dictionary. Return if any data was bound. :rtype: bool

  • var is a list prepend the text and append the tail.

  • var is present in the params assign the text and tail to the generic object.

  • Otherwise bind the given element to a new generic object.

child(qname, attrs, ns_map, position)[source]#

Initialize the next child node to be queued, when a new xml element starts.

This entry point is responsible to create the next node type with all the necessary information on how to bind the incoming input data.

  • qname (str) – Qualified name

  • attrs (Dict) – Attribute key-value map

  • ns_map (Dict) – Namespace prefix-URI map

  • position (int) – The current objects position, to mark future objects as children

Return type: