UnionNode#
- class xsdata.formats.dataclass.parsers.nodes.UnionNode(var, attrs, ns_map, position, config, context)[source]#
XmlNode for union fields with at least one data class.
The node will record all child events and in the end will replay them and try to build all possible objects and sort them by score before deciding the winner.
- Parameters:
var (
XmlVar
) – The xml var instanceattrs (
Dict
) – The element attributesns_map (
Dict
) – The element namespace prefix-URI mapposition (
int
) – The current objects length, everything after this position are considered children of this node.config (
ParserConfig
) – The parser config instancecontext (
XmlContext
) – The xml context instance
- child(qname, attrs, ns_map, position)[source]#
Record the event for the child element.
This entry point records all events, as it’s not possible to detect the target parsed object type just yet. When this node ends, it will replay all events and attempt to find the best matching type for the parsed object.
- 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 replay all xml events and parse/bind all the children objects.
- Parameters:
- Return type:
- Returns:
Always returns true, if the binding process fails it raises an exception.
- Raises:
ParserError – If none of the candidate types matched the replayed events.