Skip to content

wrapper

xsdata.formats.dataclass.parsers.nodes.wrapper

WrapperNode

Bases: XmlNode

XmlNode for wrapper class fields.

This node represents wrap class fields, that don't actually appear in the serialized document.

These fields simplify classes and this kind of node simply proxies the child requests to the parent node.

Parameters:

Name Type Description Default
parent ElementNode

The parent node

required

Attributes:

Name Type Description
ns_map

The node namespace prefix-URI map

Source code in xsdata/formats/dataclass/parsers/nodes/wrapper.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class WrapperNode(XmlNode):
    """XmlNode for wrapper class fields.

    This node represents wrap class fields, that
    don't actually appear in the serialized document.

    These fields simplify classes and this kind of
    node simply proxies the child requests to the parent
    node.

    Args:
        parent: The parent node

    Attributes:
        ns_map: The node namespace prefix-URI map
    """

    def __init__(self, parent: ElementNode):
        self.parent = parent
        self.ns_map = parent.ns_map

    def bind(
        self, qname: str, text: Optional[str], tail: Optional[str], objects: List
    ) -> bool:
        """This node will never appear in the xml, so it never binds any data.

        Args:
            qname: The element qualified name
            text: The element text content
            tail: The element tail content
            objects: The list of intermediate parsed objects

        Returns:
            Always false because no binding takes place.
        """
        return False

    def child(self, qname: str, attrs: Dict, ns_map: Dict, position: int) -> XmlNode:
        """Proxy the next child node to the parent node.

        Args:
            qname: The element qualified name
            attrs: The element attributes
            ns_map: The element namespace prefix-URI map
            position: The current length of the intermediate objects

        Returns:
            The child xml node instance.
        """
        return self.parent.child(qname, attrs, ns_map, position)

bind(qname, text, tail, objects)

This node will never appear in the xml, so it never binds any data.

Parameters:

Name Type Description Default
qname str

The element qualified name

required
text Optional[str]

The element text content

required
tail Optional[str]

The element tail content

required
objects List

The list of intermediate parsed objects

required

Returns:

Type Description
bool

Always false because no binding takes place.

Source code in xsdata/formats/dataclass/parsers/nodes/wrapper.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def bind(
    self, qname: str, text: Optional[str], tail: Optional[str], objects: List
) -> bool:
    """This node will never appear in the xml, so it never binds any data.

    Args:
        qname: The element qualified name
        text: The element text content
        tail: The element tail content
        objects: The list of intermediate parsed objects

    Returns:
        Always false because no binding takes place.
    """
    return False

child(qname, attrs, ns_map, position)

Proxy the next child node to the parent node.

Parameters:

Name Type Description Default
qname str

The element qualified name

required
attrs Dict

The element attributes

required
ns_map Dict

The element namespace prefix-URI map

required
position int

The current length of the intermediate objects

required

Returns:

Type Description
XmlNode

The child xml node instance.

Source code in xsdata/formats/dataclass/parsers/nodes/wrapper.py
44
45
46
47
48
49
50
51
52
53
54
55
56
def child(self, qname: str, attrs: Dict, ns_map: Dict, position: int) -> XmlNode:
    """Proxy the next child node to the parent node.

    Args:
        qname: The element qualified name
        attrs: The element attributes
        ns_map: The element namespace prefix-URI map
        position: The current length of the intermediate objects

    Returns:
        The child xml node instance.
    """
    return self.parent.child(qname, attrs, ns_map, position)