ElementNode#
- 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.
- Parameters:
meta (
XmlMeta
) – The class binding metadata instanceattrs (
Dict
) – The element attributesns_map (
Dict
) – The element namespace prefix-URI mapconfig (
ParserConfig
) – The parser config instancecontext (
XmlContext
) – The models context instanceposition (
int
) – The current objects length, everything after this position are considered children of this node.mixed (
bool
) – Specifies whether this node supports mixed content.xsi_nil (
Optional
[bool
]) – Specifies whether element has the xsi:nil attribute
- assigned#
A set to store the processed sub-nodes
- tail_processed#
Whether the tail process is consumed
- bind(qname, text, tail, objects)[source]#
Bind the parsed data into an object for the ending element.
This entry point is called when a xml element ends and is responsible to parse the current element attributes/text, bind any children objects and initialize new object.
- bind_attrs(params)[source]#
Parse the element attributes.
- Scenarios:
Each attribute matches a class field
Class has a wildcard field that sucks everything else
- bind_objects(params, objects)[source]#
Bind children objects.
Emit a warning if an object doesn’t fit in any class parameters.
- bind_wild_var(params, var, qname, value)[source]#
Bind a child object to a wildcard field.
The wildcard might support one or more values. If it supports only one the values are nested under a parent generic element instance.
- bind_mixed_objects(params, var, objects)[source]#
Bind children objects to a mixed content wildcard field.
- bind_wild_text(params, var, text, tail)[source]#
Bind the element text and tail content to a wildcard field.
If the field is a list, prepend the text and append the tail content. Otherwise, build a generic element with the text/tail content and any attributes. If the field is already occupied, then this means the current node is a child, and we need to nested them.
- child(qname, attrs, ns_map, position)[source]#
Initialize the next child node to be queued, when an 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.
- build_node(qname, var, attrs, ns_map, position)[source]#
Build the next child node based on the xml var instance.
- Parameters:
- Return type:
Optional
[XmlNode
]- Returns:
The next child node instance, or None if nothing matched the starting element.
- build_element_node(clazz, derived, nillable, attrs, ns_map, position, derived_factory, xsi_type=None, xsi_nil=None)[source]#
Build the next element child node.
- Parameters:
clazz (
Type
) – The target classderived (
bool
) – Whether derived elements should wrap the parsed objectnillable (
bool
) – Specifies whether nil content is allowedattrs (
Dict
) – The element attributesns_map (
Dict
) – The element namespace prefix-URI mapposition (
int
) – The current length of the intermediate objectsderived_factory (
Type
) – The derived factoryxsi_nil (
Optional
[bool
]) – Specifies whether the node supports nillable content
- Return type:
- Returns:
The next child element node instance, or None if the clazz doesn’t match the starting element.