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 and dataclasses.
- Parameters:
meta (
XmlMeta
) – Model xml metadataattrs (
Dict
) – Key-value attribute mappingns_map (
Dict
) – Namespace prefix-URI mapconfig (
ParserConfig
) – Parser configurationcontext (
XmlContext
) – Model context providerposition (
int
) – The node position of objects cachemixed (
bool
) – The node supports mixed content
- 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.
- bind_attrs(params)[source]#
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:
- Returns:
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, var)[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.