xsdata.codegen.models module

xsdata.codegen.models.qname(name, ns_map, default_namespace=None)[source]

Create an lxml.etree.QName for the given name and namespaces map.

Use the default namespace if the prefix is not in the ns_map.

Parameters
Return type

QName

class xsdata.codegen.models.Restrictions(required=None, prohibited=None, min_occurs=None, max_occurs=None, min_exclusive=None, min_inclusive=None, min_length=None, max_exclusive=None, max_inclusive=None, max_length=None, total_digits=None, fraction_digits=None, length=None, white_space=None, pattern=None, explicit_timezone=None, nillable=None, sequential=None)[source]

Bases: object

Model representation of a dataclass field validation and type metadata.

Parameters
required: Optional[bool] = None
prohibited: Optional[bool] = None
min_occurs: Optional[int] = None
max_occurs: Optional[int] = None
min_exclusive: Optional[float] = None
min_inclusive: Optional[float] = None
min_length: Optional[float] = None
max_exclusive: Optional[float] = None
max_inclusive: Optional[float] = None
max_length: Optional[float] = None
total_digits: Optional[int] = None
fraction_digits: Optional[int] = None
length: Optional[int] = None
white_space: Optional[str] = None
pattern: Optional[str] = None
explicit_timezone: Optional[str] = None
nillable: Optional[bool] = None
sequential: Optional[bool] = None
property is_list

Return true if max occurs property is larger than one.

Return type

bool

property is_optional

Return true if min occurs property equals zero.

Return type

bool

merge(source)[source]

Update properties from another instance.

Parameters

source (Restrictions) –

asdict()[source]

Return the initialized only properties as a dictionary.

Return type

Dict

clone()[source]

Return a deep cloned instance.

Return type

Restrictions

classmethod from_element(element)[source]

Static constructor from an xsd model.

Parameters

element (ElementBase) –

Return type

Restrictions

class xsdata.codegen.models.AttrType(name, index=<factory>, alias=None, native=False, forward=False, circular=False)[source]

Bases: object

Model representation for the typing information for fields and extensions.

Parameters
name: str
index: int
alias: Optional[str] = None
native: bool = False
forward: bool = False
circular: bool = False
property is_dependency

Return true if attribute is not a forward/circular references and it’s not a native python time.

Return type

bool

property native_name

Return the python build-in type name: ‘str’, ‘int’ if it’s native type.

Return type

Optional[str]

property native_code

Return the xml data type if it’s native type.

Return type

Optional[str]

property native_type

Return the python build-in type if it’s a native type.

Return type

Any

clone()[source]

Return a deep cloned instance.

Return type

AttrType

class xsdata.codegen.models.Attr(tag, name, index, local_name=None, default=None, fixed=False, types=<factory>, display_type=None, namespace=None, help=None, restrictions=<factory>)[source]

Bases: object

Model representation for a dataclass field.

Parameters
tag: str
name: str
index: int
local_name: Optional[str] = None
default: Any = None
fixed: bool = False
types: List[AttrType]
display_type: Optional[str] = None
namespace: Optional[str] = None
help: Optional[str] = None
restrictions: Restrictions
property is_attribute

Return whether this attribute is derived from an xs:attribute or xs:anyAttribute.

Return type

bool

property is_enumeration

Return whether this attribute is derived from an xs:enumeration.

Return type

bool

property is_factory

Return whether this attribute is a list of items or a mapping.

Return type

bool

property is_group

Return whether this attribute is derived from an xs:group or xs:attributeGroup.

Return type

bool

property is_map

Return whether this attribute is a mapping of values.

Return type

bool

property is_nameless

Return whether this attribute has a local name that will be used during parsing/serialization.

Return type

bool

property is_list

Return whether this attribute is a list of values.

Return type

bool

property is_optional

Return whether this attribute is not required.

Return type

bool

property is_suffix

Return whether this attribute is not derived from an xs element with mode suffix.

Return type

bool

property is_xsi_type

Return whether this attribute qualified name is equal to xsi:type.

Return type

bool

property is_wildcard

Return whether this attribute is derived from xs:anyAttribute or xs:any.

Return type

bool

property xml_type

Return the xml node type this attribute is mapped to.

Return type

Optional[str]

clone()[source]

Return a deep cloned instance.

Return type

Attr

class xsdata.codegen.models.Extension(type, restrictions)[source]

Bases: object

Model representation of a dataclass base class.

Parameters
Restrictions type

type: AttrType
restrictions: Restrictions
clone()[source]

Return a deep cloned instance.

Return type

Extension

class xsdata.codegen.models.Status(value)[source]

Bases: enum.IntEnum

An enumeration.

RAW = 0
PROCESSING = 1
PROCESSED = 2
class xsdata.codegen.models.Class(name, type, module, mixed, abstract, nillable, strict_type=False, status=<Status.RAW: 0>, container=None, package=None, namespace=None, help=None, substitutions=<factory>, extensions=<factory>, attrs=<factory>, inner=<factory>, ns_map=<factory>, source_namespace=None)[source]

Bases: object

Model representation of a dataclass with fields, base/inner classes and additional metadata settings.

Parameters
name: str
type: Type
module: str
mixed: bool
abstract: bool
nillable: bool
strict_type: bool = False
status: xsdata.codegen.models.Status = 0
container: Optional[str] = None
package: Optional[str] = None
namespace: Optional[str] = None
help: Optional[str] = None
substitutions: List[str]
extensions: List[Extension]
attrs: List[Attr]
inner: List[‘Class’]
ns_map: Dict
source_namespace: Optional[str] = None
property has_suffix_attr

Return whether or not it includes a suffix attribute.

Return type

bool

property has_wild_attr

Return whether or not it includes a wildcard attribute.

Return type

bool

property is_complex

Return whether or not this instance is derived from an xs:element or xs:complexType.

Return type

bool

property is_element

Return whether or not this instance is derived from an non abstract xs:element.

Return type

bool

property is_enumeration

Return whether all attributes are derived from xs:enumeration.

Return type

bool

property is_nillable

Return whether this class represents a nillable xml element.

Return type

bool

property source_prefix

Return the source namespace prefix as it was defined in the schema definition.

Return type

Optional[str]

property target_module

Return the target module this class is assigned to.

Return type

str

clone()[source]

Return a deep cloned instance.

Return type

Class

dependencies()[source]

Return a set of dependencies for the given class.

Collect:
  • base classes

  • attribute types

  • recursively go through the inner classes

  • Ignore inner class references

  • Ignore native types.

Return type

Iterator[QName]

source_qname(name=None)[source]
Parameters

name (Optional[str]) –

Return type

QName

class xsdata.codegen.models.Package(name, source, alias=None)[source]

Bases: object

Model representation of a python import statement.

Parameters
name: str
source: str
alias: Optional[str] = None