xsdata.formats.dataclass.parsers.nodes module¶
-
class
xsdata.formats.dataclass.parsers.nodes.
XmlNode
(position)[source]¶ Bases:
object
A generic interface for xml nodes that need to implement the two public methods to be used in an event based parser with start/end element events. The parser needs to maintain a queue for these nodes and a list of objects that these nodes return.
- Parameters
position (
int
) – The current objects size, when the node is created.
-
next_node
(element, position, ctx)[source]¶ Initialize the next 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.
- Parameters
element (
Element
) –position (
int
) –ctx (
XmlContext
) –
- Return type
-
class
xsdata.formats.dataclass.parsers.nodes.
ElementNode
(position, meta, config)[source]¶ Bases:
xsdata.formats.dataclass.parsers.nodes.XmlNode
Element type node is equivalent to xml elements and is used to bind user defined dataclasses.
- Parameters
meta (
XmlMeta
) – xml metadata of a dataclass model.config (
ParserConfig
) – Parser config instance passed down from the root node.position (
int
) –
-
meta
: XmlMeta¶
-
config
: ParserConfig¶
-
parse_element
(element, objects)[source]¶ Parse the given element attributes/text, find all child objects and mixed content and initialize a new dataclass instance.
-
next_node
(element, position, ctx)[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.
- Return type
- Returns
The next node to be queued.
- Raises
XmlContextError if the element is unknown and parser config is strict.
- Parameters
element (
Element
) –position (
int
) –ctx (
XmlContext
) –
-
class
xsdata.formats.dataclass.parsers.nodes.
RootNode
(position, meta, config)[source]¶ Bases:
xsdata.formats.dataclass.parsers.nodes.ElementNode
- Parameters
position (
int
) –meta (
XmlMeta
) –config (
ParserConfig
) –
-
next_node
(element, position, ctx)[source]¶ Override parent to return itself if the current element is root.
- Parameters
element (
Element
) –position (
int
) –ctx (
XmlContext
) –
- Return type
-
meta
¶
-
config
¶
-
class
xsdata.formats.dataclass.parsers.nodes.
WildcardNode
(position, qname)[source]¶ Bases:
xsdata.formats.dataclass.parsers.nodes.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
qname (
QName
) – xml element tagposition (
int
) –
-
qname
: QName¶
-
parse_element
(element, objects)[source]¶ Parse the given element attributes/text/tail, find all child objects and mixed content and initialize a new generic element instance.
- Return type
- Returns
A tuple of the object’s qualified name and a new
xsdata.formats.dataclass.models.generics.AnyElement
instance.- Parameters
-
next_node
(element, position, ctx)[source]¶ Initialize the next wildcard node to be queued for the given starting element.
Notes: Wildcard nodes can only queue other wildcard nodes.
- Parameters
element (
Element
) –position (
int
) –ctx (
XmlContext
) –
- Return type
-
class
xsdata.formats.dataclass.parsers.nodes.
PrimitiveNode
(position, var)[source]¶ Bases:
xsdata.formats.dataclass.parsers.nodes.XmlNode
-
var
: XmlVar¶
-
parse_element
(element, objects)[source]¶ Parse the given element text according to the node possible types.
-
next_node
(element, position, ctx)[source]¶ Initialize the next 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.
- Parameters
element (
Element
) –position (
int
) –ctx (
XmlContext
) –
- Return type
-
-
class
xsdata.formats.dataclass.parsers.nodes.
SkipNode
(position)[source]¶ Bases:
xsdata.formats.dataclass.parsers.nodes.XmlNode
This node is used by the parser to skip unknown elements and their children.
The result of the next_node is always another SkipNode and the result of parse_element is always a tuple of None values.
- Parameters
position (
int
) –
-
next_node
(element, position, ctx)[source]¶ Initialize the next 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.
- Parameters
element (
Element
) –position (
int
) –ctx (
XmlContext
) –
- Return type
-
parse_element
(element, objects)[source]¶ Parse the current element bind child objects and return the result.
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 a new object.
-
position
¶