xsdata.formats.dataclass.parsers.nodes module¶
-
class
xsdata.formats.dataclass.parsers.nodes.
ElementNode
(meta, attrs, ns_map, config, context, position, mixed=False, derived=False)[source]¶ Bases:
xsdata.formats.dataclass.parsers.mixins.XmlNode
Element type node is equivalent to xml elements and is used to bind user defined dataclasses.
- Parameters
meta (
XmlMeta
) – Model xml metadataattrs (
Dict
) – Key-value attribute mappingns_map (
Dict
) – Prefix-URI Namespace mappingconfig (
ParserConfig
) – Parser configurationcontext (
XmlContext
) – Model xml metadata builderposition (
int
) – The node position of objects cachederived (
bool
) – The xml element is derived from a base typemixed (
bool
) –
-
attrs
: Dict¶
-
ns_map
: Dict¶
-
FIND_MODES_ORDERED
: ClassVar[Iterable[xsdata.formats.dataclass.models.elements.FindMode]] = (<FindMode.NOT_WILDCARD: 6>, <FindMode.WILDCARD: 5>)¶
-
bind
(qname, text, tail, objects)[source]¶ Parse the given element attributes/text, find all child objects and mixed content and initialize a new dataclass instance.
-
child
(qname, attrs, ns_map, position)[source]¶ Initialize the next node to be queued for the given starting element.
Search by the given element tag for a matching variable and create the next node by the variable type.
-
class
xsdata.formats.dataclass.parsers.nodes.
AnyTypeNode
(var, attrs, ns_map, position, mixed=False)[source]¶ Bases:
xsdata.formats.dataclass.parsers.mixins.XmlNode
-
attrs
: Dict¶
-
ns_map
: Dict¶
-
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.
-
-
class
xsdata.formats.dataclass.parsers.nodes.
WildcardNode
(var, attrs, ns_map, position)[source]¶ Bases:
xsdata.formats.dataclass.parsers.mixins.XmlNode
Wildcard nodes are used for extensible elements that can hold any attribute and content and don’t have a specific dataclass or primitive type.
- Notes:
In the future this node should check all known user defined models in the target namespace and use that instead of the generic.
- Parameters
-
attrs
: Dict¶
-
ns_map
: Dict¶
-
class
xsdata.formats.dataclass.parsers.nodes.
UnionNode
(var, attrs, ns_map, position, context, level=<factory>, events=<factory>)[source]¶ Bases:
xsdata.formats.dataclass.parsers.mixins.XmlNode
Union nodes are used for variables with more than one possible types where at least one of them is a dataclass.
- Parameters
-
attrs
: Dict¶
-
ns_map
: Dict¶
-
events
: List¶
-
child
(qname, attrs, ns_map, position)[source]¶ Skip all child nodes as we are going to parse the complete element tree.
-
bind
(qname, text, tail, objects)[source]¶ The handler will make multiple tries to bind the given element to one of the available dataclass var types convert it to one of the available primitive types.
The first shoe that fits wins!
-
class
xsdata.formats.dataclass.parsers.nodes.
PrimitiveNode
(var, ns_map)[source]¶ Bases:
xsdata.formats.dataclass.parsers.mixins.XmlNode
XmlNode for text elements with primitive values eg str, int, float.
-
ns_map
: Dict¶
-
bind
(qname, text, tail, objects)[source]¶ Parse the given element text according to the node possible types.
-
-
class
xsdata.formats.dataclass.parsers.nodes.
SkipNode
[source]¶ Bases:
xsdata.formats.dataclass.parsers.mixins.XmlNode
The skip node should be used when we want to skip parsing child elements.
-
class
xsdata.formats.dataclass.parsers.nodes.
NodeParser
(config=<factory>, context=<factory>, handler=<class 'xsdata.formats.dataclass.parsers.mixins.EventsHandler'>)[source]¶ Bases:
xsdata.formats.dataclass.parsers.mixins.PushParser
Bind xml nodes to dataclasses.
- Parameters
config (
ParserConfig
) – Parser configurationcontext (
XmlContext
) – Model metadata builderhandler (
Type
[XmlHandler
]) – Override default XmlHandlerms_map – Namespace registry for prefix-URI mappings
-
handler
¶ alias of
xsdata.formats.dataclass.parsers.mixins.EventsHandler
-
ns_map
: Dict¶
-
class
xsdata.formats.dataclass.parsers.nodes.
RecordParser
(config=<factory>, context=<factory>, handler=<class 'xsdata.formats.dataclass.parsers.mixins.EventsHandler'>, events=<factory>)[source]¶ Bases:
xsdata.formats.dataclass.parsers.nodes.NodeParser
Bind xml nodes to dataclasses with an events recorder.
- Parameters
events (
List
) – List of pushed eventsconfig (
ParserConfig
) –context (
XmlContext
) –handler (
Type
[XmlHandler
]) –
-
events
: List¶