xsdata.models.mixins module

class xsdata.models.mixins.ElementBase[source]

Bases: object

Base xsd schema model.

Parameters
  • index – Occurrence position inside the definition

  • ns_map – prefix-URI Namespace mapping

index: int
ns_map: Dict
property class_name

Return the schema element class name.

Return type

str

property default_type

Return the default type if the given element has not specific type.

Return type

str

property default_value

Return the default or the fixed attribute value.

Return type

Any

property display_help

Return the display help for this element.

Return type

Optional[str]

property extensions

Return an iterator of all the base types.

Return type

Iterator[str]

property has_children

Return whether or not this element has any children.

Return type

bool

property has_form

Return whether or not this element has the form attribute.

Return type

bool

property is_abstract

Return whether or not this element is defined as abstract.

Return type

bool

property is_attribute

Return whether or not this element is qualified to be a class attribute.

Return type

bool

property is_fixed

Return whether or not this element has a fixed value.

Return type

bool

property is_mixed

Return whether or not this element accepts mixed content value.

Return type

bool

property is_nillable

Return whether or not this element is accepts empty empty values.

Return type

bool

property is_qualified

Return whether or not this element name needs to be referenced with the target namespace.

Return type

bool

property is_ref

Return whether or not this element is a reference to another element.

Return type

bool

property is_wildcard

Return whether or not this element is a wildcard element/attribute.

Return type

bool

property prefix

Return the namespace prefix for this element’s type.

Return type

Optional[str]

property raw_namespace

Return if present the target namespace attribute value.

Return type

Optional[str]

property raw_type

Return if present the type attribute value.

Return type

Optional[str]

property real_name

Return the real name for this element by looking by looking either to the name or ref attribute value.

Raises

SchemaValueError – when instance has no name/ref attribute.

Return type

str

property real_type

Return the real type for this element.

Raises

SchemaValueError – when attribute instance is missing implementation.

Return type

str

property substitutions

Return the substitution groups of this element.

Return type

List[str]

property token_types

Return a list of the token style data type names with the xml schema prefix.

Return type

List[str]

data_type_ref(data_type)[source]

Return the given data type code with the xml schema namespace prefix if any.

Parameters

data_type (DataType) –

Return type

str

get_restrictions()[source]

Return the restrictions dictionary of this element.

Return type

Dict[str, Any]

children(condition=<function return_true>)[source]

Iterate over all the ElementBase children of this element that match the given condition if any.

Parameters

condition (Callable) –

Return type

Iterator[ElementBase]

class xsdata.models.mixins.ModuleMixin[source]

Bases: object

property module

Return a valid module name based on the instance location uri.

Return type

str

xsdata.models.mixins.attribute(optional=True, **kwargs)[source]

Shortcut method for attribute fields.

Parameters
  • optional (bool) –

  • kwargs (Any) –

Return type

Any

xsdata.models.mixins.element(optional=True, **kwargs)[source]

Shortcut method for element fields.

Parameters
  • optional (bool) –

  • kwargs (Any) –

Return type

Any

xsdata.models.mixins.array_element(**kwargs)[source]

Shortcut method for list element fields.

Parameters

kwargs (Any) –

Return type

Any

xsdata.models.mixins.array_any_element(**kwargs)[source]

Shortcut method for list wildcard fields.

Parameters

kwargs (Any) –

Return type

Any

xsdata.models.mixins.extract_metadata(params, **kwargs)[source]

Extract not standard dataclass field parameters to a new metadata dictionary and merge with any provided keyword arguments.

Parameters
  • params (Dict) –

  • kwargs (Any) –

Return type

Dict

xsdata.models.mixins.has_default(params)[source]

Chek if default value or factory exists in the given params.

Parameters

params (Dict) –

Return type

bool