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`

     5
     6
     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

    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):
            """Initialize the xml node."""
            self.parent = parent
            self.ns_map = parent.ns_map

        def bind(
            self, qname: str, text: str | None, tail: str | None, 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)

#### `__init__(parent)`

Initialize the xml node.

Source code in `xsdata/formats/dataclass/parsers/nodes/wrapper.py`

    22
    23
    24
    25

    def __init__(self, parent: ElementNode):
        """Initialize the xml node."""
        self.parent = parent
        self.ns_map = parent.ns_map

#### `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` | `str | None` | The element text content | required
`tail` | `str | None` | 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`

    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41

    def bind(
        self, qname: str, text: str | None, tail: str | None, 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`

    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55

    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)