xsdata.formats.dataclass.models.elements module

class xsdata.formats.dataclass.models.elements.XmlVar(name, qname, init=True, nillable=False, dataclass=False, sequential=False, default=None, types=<factory>, namespaces=<factory>)[source]

Bases: object

Dataclass field bind metadata.

Parameters
  • name (str) – field name,

  • qname (QName) – qualified local name,

  • init (bool) – field is present in the constructor arguments.

  • nillable (bool) – allow to render empty nillable elements,

  • dataclass (bool) – field type is a dataclass or a primitive type.

  • sequential (bool) – switch to sequential rendering with other sequential siblings,

  • default (Optional[Any]) – default value or factory

  • types (List[Type]) – field bind or cast types.

  • namespaces (List[str]) – a list of the all the possible namespaces.

name: str
qname: QName
init: bool = True
nillable: bool = False
dataclass: bool = False
sequential: bool = False
default: Any = None
types: List[Type]
namespaces: List[str]
property clazz

Return the first type if field is bound to a dataclass.

Return type

Optional[Type]

property is_any_type

Return whether or not the field type is xs:anyType.

Return type

bool

property is_attribute

Return whether or not the field is derived from xs:attribute.

Return type

bool

property is_attributes

Return whether or not the field is derived from xs:anyAttributes.

Return type

bool

property is_element

Return whether or not the field is derived from xs:element.

Return type

bool

property is_list

Return whether or not the field is a list of elements.

Return type

bool

property is_text

Return whether or not the field is a text element.

Return type

bool

property is_tokens

Return whether or not the field is a list of tokens.

Return type

bool

property is_wildcard

Return whether or not the field is a text element.

Return type

bool

matches(qname)[source]

Match the field qualified local name to the given qname.

Return True automatically if the local name is a wildcard.

Parameters

qname (QName) –

Return type

bool

class xsdata.formats.dataclass.models.elements.XmlElement(name, qname, init=True, nillable=False, dataclass=False, sequential=False, default=None, types=<factory>, namespaces=<factory>)[source]

Bases: xsdata.formats.dataclass.models.elements.XmlVar

Dataclass field bind metadata for xml elements.

Parameters
property is_element

Return whether or not the field is derived from xs:element.

Return type

bool

property is_any_type

Return whether or not the field type is xs:anyType.

Return type

bool

name
qname
types
namespaces
class xsdata.formats.dataclass.models.elements.XmlWildcard(name, qname, init=True, nillable=False, dataclass=False, sequential=False, default=None, types=<factory>, namespaces=<factory>)[source]

Bases: xsdata.formats.dataclass.models.elements.XmlVar

Dataclass field bind metadata for xml wildcard elements.

Parameters
property is_wildcard

Return whether or not the field is a text element.

Return type

bool

property is_any_type

Return whether or not the field type is xs:anyType.

Return type

bool

matches(qname)[source]

Match the given qname to the wildcard allowed namespaces.

Parameters

qname (QName) –

Return type

bool

name
qname
types
namespaces
class xsdata.formats.dataclass.models.elements.XmlAttribute(name, qname, init=True, nillable=False, dataclass=False, sequential=False, default=None, types=<factory>, namespaces=<factory>)[source]

Bases: xsdata.formats.dataclass.models.elements.XmlVar

Dataclass field bind metadata for xml attributes.

Parameters
property is_attribute

Return whether or not the field is derived from xs:attribute.

Return type

bool

name
qname
types
namespaces
class xsdata.formats.dataclass.models.elements.XmlAttributes(name, qname, init=True, nillable=False, dataclass=False, sequential=False, default=None, types=<factory>, namespaces=<factory>)[source]

Bases: xsdata.formats.dataclass.models.elements.XmlVar

Dataclass field bind metadata for xml wildcard attributes.

Parameters
property is_attributes

Return whether or not the field is derived from xs:anyAttributes.

Return type

bool

name
qname
types
namespaces
class xsdata.formats.dataclass.models.elements.XmlText(name, qname, init=True, nillable=False, dataclass=False, sequential=False, default=None, types=<factory>, namespaces=<factory>)[source]

Bases: xsdata.formats.dataclass.models.elements.XmlVar

Dataclass field bind metadata for xml text content.

Parameters
property is_tokens

Return whether or not the field is a list of tokens.

Return type

bool

property is_text

Return whether or not the field is a text element.

Return type

bool

name
qname
types
namespaces
class xsdata.formats.dataclass.models.elements.FindMode(value)[source]

Bases: enum.IntEnum

Find switches to be used to find a specific var.

ALL = 1
ATTRIBUTE = 2
ATTRIBUTES = 3
ELEMENT = 4
TEXT = 5
WILDCARD = 6
NOT_WILDCARD = 7
LIST = 8
NOT_LIST = 9
class xsdata.formats.dataclass.models.elements.XmlMeta(name, clazz, qname, source_qname, nillable, vars=<factory>, cache=<factory>)[source]

Bases: object

Dataclass model bind metadata.

Parameters
  • name (str) – local name

  • clazz (Type) – dataclass type

  • qname (QName) – local name qualified with target namespace.

  • source_qname (QName) – local name qualified with source namespace.

  • nillable (bool) – allow render as empty element.

  • vars (List[XmlVar]) – list of field metadata

  • cache (Dict) – field lookup cache

name: str
clazz: Type
qname: QName
source_qname: QName
nillable: bool
vars: List[XmlVar]
cache: Dict
property element_form

Return element form: qualified/unqualified.

Return type

FormType

find_var(qname=<lxml.etree.QName object>, mode=<FindMode.ALL: 1>)[source]

Find a field by it’s qualified name and the specified type.

The lookup process is cached.

Parameters
Return type

Optional[XmlVar]