Skip to content

# dtd

## `xsdata.models.dtd`

### `DtdElementType`

Bases: `Enum`

DTD Element type enumeration.

Source code in `xsdata/models/dtd.py`

     9
    10
    11
    12
    13
    14
    15
    16

    class DtdElementType(enum.Enum):
        """DTD Element type enumeration."""

        UNDEFINED = "undefined"
        EMPTY = "empty"
        ANY = "any"
        MIXED = "mixed"
        ELEMENT = "element"

### `DtdAttributeDefault`

Bases: `Enum`

DTD Attribute default enumeration.

Source code in `xsdata/models/dtd.py`

    19
    20
    21
    22
    23
    24
    25

    class DtdAttributeDefault(enum.Enum):
        """DTD Attribute default enumeration."""

        REQUIRED = "required"
        IMPLIED = "implied"
        FIXED = "fixed"
        NONE = "none"

### `DtdAttributeType`

Bases: `Enum`

DTD Attribute type enumeration.

Source code in `xsdata/models/dtd.py`

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

    class DtdAttributeType(enum.Enum):
        """DTD Attribute type enumeration."""

        CDATA = "cdata"
        ID = "id"
        IDREF = "idref"
        IDREFS = "idrefs"
        ENTITY = "entity"
        ENTITIES = "entities"
        NMTOKEN = "nmtoken"
        NMTOKENS = "nmtokens"
        ENUMERATION = "enumeration"
        NOTATION = "notation"

### `DtdContentType`

Bases: `Enum`

DTD Content type enumeration.

Source code in `xsdata/models/dtd.py`

    43
    44
    45
    46
    47
    48
    49

    class DtdContentType(enum.Enum):
        """DTD Content type enumeration."""

        PCDATA = "pcdata"
        ELEMENT = "element"
        SEQ = "seq"
        OR = "or"

### `DtdContentOccur`

Bases: `Enum`

DTD Content occur enumeration.

Source code in `xsdata/models/dtd.py`

    52
    53
    54
    55
    56
    57
    58

    class DtdContentOccur(enum.Enum):
        """DTD Content occur enumeration."""

        ONCE = "once"
        OPT = "opt"
        MULT = "mult"
        PLUS = "plus"

### `DtdAttribute` `dataclass`

DTD Attribute model representation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`name` | `str` | The attribute name | required
`prefix` | `str | None` | The attribute namespace prefix | required
`type` | `DtdAttributeType` | The attribute type | required
`default` | `DtdAttributeDefault` | The attribute default type | required
`default_value` | `str | None` | The attribute default value | required
`values` | `list[str]` | The available choices as value | required

Source code in `xsdata/models/dtd.py`

    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84

    @dataclass
    class DtdAttribute:
        """DTD Attribute model representation.

        Args:
            name: The attribute name
            prefix: The attribute namespace prefix
            type: The attribute type
            default: The attribute default type
            default_value: The attribute default value
            values: The available choices as value
        """

        name: str
        prefix: str | None
        type: DtdAttributeType
        default: DtdAttributeDefault
        default_value: str | None
        values: list[str]

        @property
        def data_type(self) -> DataType:
            """Return the data type instance from the attribute type."""
            return DataType.from_code(self.type.value.lower())

#### `data_type` `property`

Return the data type instance from the attribute type.

### `DtdContent` `dataclass`

DTD Content model representation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`name` | `str` | The content name | required
`type` | `DtdContentType` | The content type | required
`occur` | `DtdContentOccur` | The content occur type | required
`left` | `Optional[DtdContent]` | The parent content | required
`right` | `Optional[DtdContent]` | The child content | required

Source code in `xsdata/models/dtd.py`

     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103

    @dataclass
    class DtdContent:
        """DTD Content model representation.

        Args:
            name: The content name
            type: The content type
            occur: The content occur type
            left: The parent content
            right: The child content
        """

        name: str
        type: DtdContentType
        occur: DtdContentOccur
        left: Optional["DtdContent"]
        right: Optional["DtdContent"]

### `DtdElement` `dataclass`

DTD Element model representation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`name` | `str` | The element name | required
`type` | `DtdElementType` | The element type | required
`prefix` | `str | None` | The element namespace prefix | required
`content` | `DtdContent | None` | The element content | required
`attributes` | `list[DtdAttribute]` | The element attribute list | required
`ns_map` | `dict` | The namespace prefix-URI map | required

Source code in `xsdata/models/dtd.py`

    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130

    @dataclass
    class DtdElement:
        """DTD Element model representation.

        Args:
            name: The element name
            type: The element type
            prefix: The element namespace prefix
            content: The element content
            attributes: The element attribute list
            ns_map: The namespace prefix-URI map
        """

        name: str
        type: DtdElementType
        prefix: str | None
        content: DtdContent | None
        attributes: list[DtdAttribute]
        ns_map: dict

        @property
        def qname(self) -> str:
            """Return the element qualified name."""
            namespace = self.ns_map.get(self.prefix)
            return build_qname(namespace, self.name)

#### `qname` `property`

Return the element qualified name.

### `Dtd` `dataclass`

The DTD Document model representation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`location` | `str` | The source location URI | required
`elements` | `list[DtdElement]` | The list of included elements | required

Source code in `xsdata/models/dtd.py`

    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143

    @dataclass
    class Dtd:
        """The DTD Document model representation.

        Args:
            location: The source location URI
            elements: The list of included elements
        """

        location: str
        elements: list[DtdElement]