Skip to content

config

xsdata.formats.dataclass.serializers.config

SerializerConfig dataclass

Serializer configuration options.

Not all options are applicable for both xml and json documents.

Parameters:

Name Type Description Default
encoding str

Text encoding

'UTF-8'
xml_version str

XML Version number (1.0|1.1)

'1.0'
xml_declaration bool

Generate XML declaration

True
pretty_print bool

Enable pretty output

False
pretty_print_indent Optional[str]

Indentation string for each indent level

None
ignore_default_attributes bool

Ignore optional attributes with default values

False
schema_location Optional[str]

xsi:schemaLocation attribute value

None
no_namespace_schema_location Optional[str]

xsi:noNamespaceSchemaLocation attribute value

None
globalns Optional[Dict[str, Callable]]

Dictionary containing global variables to extend or overwrite for typing

None
Source code in xsdata/formats/dataclass/serializers/config.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
@dataclass
class SerializerConfig:
    """Serializer configuration options.

    Not all options are applicable for both xml and json documents.

    Args:
        encoding: Text encoding
        xml_version: XML Version number (1.0|1.1)
        xml_declaration: Generate XML declaration
        pretty_print: Enable pretty output
        pretty_print_indent: Indentation string for each indent level
        ignore_default_attributes: Ignore optional attributes with default values
        schema_location: xsi:schemaLocation attribute value
        no_namespace_schema_location: xsi:noNamespaceSchemaLocation attribute value
        globalns: Dictionary containing global variables to extend or
            overwrite for typing
    """

    encoding: str = "UTF-8"
    xml_version: str = "1.0"
    xml_declaration: bool = True
    pretty_print: bool = False
    pretty_print_indent: Optional[str] = None
    ignore_default_attributes: bool = False
    schema_location: Optional[str] = None
    no_namespace_schema_location: Optional[str] = None
    globalns: Optional[Dict[str, Callable]] = None