xsdata.models.elements module

class xsdata.models.elements.Documentation(id, prefix, nsmap, index, lang, source, text)[source]

Bases: xsdata.models.mixins.ElementBase

The documentation element is used to enter text comments in a schema.

Reference: https://www.w3schools.com/xml/el_documentation.asp.

lang: Optional[str] = None
source: Optional[str] = None
text: Optional[str] = None
class xsdata.models.elements.Appinfo(id, prefix, nsmap, index, source)[source]

Bases: xsdata.models.mixins.ElementBase

The appinfo element specifies information to be used by the application.

Reference: https://www.w3schools.com/xml/el_appinfo.asp.

source: Optional[str] = None
class xsdata.models.elements.Annotation(id, prefix, nsmap, index, appinfo, documentations=<factory>)[source]

Bases: xsdata.models.mixins.ElementBase

The annotation element is a top level element that specifies schema comments.

Reference: https://www.w3schools.com/xml/el_annotation.asp.

appinfo: Optional[Appinfo] = None
documentations: ArrayList[Documentation] = None
class xsdata.models.elements.AnnotationBase(id, prefix, nsmap, index, annotation)[source]

Bases: xsdata.models.mixins.ElementBase

Base Class for elements that can contain annotations.

annotation: Optional[Annotation] = None
property display_help
Return type

Optional[str]

class xsdata.models.elements.SimpleType(id, prefix, nsmap, index, annotation, name, restriction, list, union)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.TypedField, xsdata.models.mixins.NamedField, xsdata.models.mixins.RestrictedField

The simpleType element defines a simple type and specifies the constraints and information about the values of attributes or text-only elements.

XSD Element reference : Reference: https://www.w3schools.com/xml/el_simpletype.asp.

name: Optional[str] = None
restriction: Optional['Restriction'] = None
list: Optional['List'] = None
union: Optional['Union'] = None
property real_type
Return type

Optional[str]

get_restrictions()[source]
Return type

Dict[str, Any]

class xsdata.models.elements.List(id, prefix, nsmap, index, annotation, item_type, simple_type)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.RestrictedField

The list element defines a simple type element as a list of values of a specified data type.

Reference: https://www.w3schools.com/xml/el_list.asp.

item_type: Optional[str] = None
simple_type: SimpleType = None
property real_type
Return type

Optional[str]

get_restrictions()[source]
Return type

Dict[str, Any]

class xsdata.models.elements.Union(id, prefix, nsmap, index, annotation, member_types, simple_types=<factory>)[source]

Bases: xsdata.models.elements.AnnotationBase

The union element defines a simple type as a collection (union) of values from specified simple data types.

Reference: https://www.w3schools.com/xml/el_union.asp.

member_types: Optional[str] = None
simple_types: ArrayList[SimpleType] = None
property extends
Return type

Optional[str]

class xsdata.models.elements.AnyAttribute(id, prefix, nsmap, index, annotation, namespace, process_contents, simple_type)[source]

Bases: xsdata.models.elements.AnnotationBase

The anyAttribute element enables the author to extend the XML document with attributes not specified by the schema.

XSD Element reference

: Reference: https://www.w3schools.com/xml/el_anyattribute.asp.

namespace: Optional[str] = None
process_contents: Optional[ProcessType] = None
simple_type: Optional[SimpleType] = None
class xsdata.models.elements.Attribute(id, prefix, nsmap, index, annotation, default, fixed, form, name, ref, type, simple_type, use=<UseType.OPTIONAL: 'optional'>)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.TypedField, xsdata.models.mixins.NamedField, xsdata.models.mixins.RestrictedField

The attribute element defines an attribute.

Reference: https://www.w3schools.com/xml/el_attribute.asp.

default: Optional[str] = None
fixed: Optional[str] = None
form: Optional[FormType] = None
name: Optional[str] = None
ref: Optional[str] = None
type: Optional[str] = None
simple_type: Optional[SimpleType] = None
use: Optional[xsdata.models.enums.UseType] = 'optional'
property is_attribute
Return type

bool

property real_type
Return type

Optional[str]

get_restrictions()[source]
Return type

Dict[str, Any]

class xsdata.models.elements.AttributeGroup(id, prefix, nsmap, index, annotation, name, ref, any_attribute, attributes=<factory>, attribute_groups=<factory>)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.NamedField

The attributeGroup element is used to group a set of attribute declarations so that they can be incorporated as a group into complex type definitions.

XSD Element reference

: Reference: https://www.w3schools.com/xml/el_attributegroup.asp.

name: Optional[str] = None
ref: Optional[str] = None
any_attribute: Optional[AnyAttribute] = None
attributes: ArrayList[Attribute] = None
attribute_groups: ArrayList['AttributeGroup'] = None
property extends
Return type

Optional[str]

class xsdata.models.elements.All(id, prefix, nsmap, index, annotation, elements=<factory>, max_occurs=1, min_occurs=1)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.OccurrencesMixin

The all element specifies that the child elements can appear in any order and that each child element can occur zero or one time.

Reference: https://www.w3schools.com/xml/el_all.asp.

elements: ArrayList['Element'] = None
max_occurs: int = 1
min_occurs: int = 1
class xsdata.models.elements.Sequence(id, prefix, nsmap, index, annotation, elements=<factory>, groups=<factory>, choices=<factory>, sequences=<factory>, anys=<factory>, max_occurs=1, min_occurs=1)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.OccurrencesMixin

The sequence element specifies that the child elements must appear in a sequence. Each child element can occur from 0 to any number of times.

Reference: https://www.w3schools.com/xml/el_sequence.asp.

elements: ArrayList['Element'] = None
groups: ArrayList['Group'] = None
choices: ArrayList['Choice'] = None
sequences: ArrayList['Sequence'] = None
anys: ArrayList['Any'] = None
max_occurs: int = 1
min_occurs: int = 1
class xsdata.models.elements.Choice(id, prefix, nsmap, index, annotation, elements=<factory>, groups=<factory>, choices=<factory>, sequences=<factory>, max_occurs=1, min_occurs=1)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.OccurrencesMixin

XML Schema choice element allows only one of the elements contained in the <choice> declaration to be present within the containing element.

Reference: https://www.w3schools.com/xml/el_choice.asp.

elements: ArrayList['Element'] = None
groups: ArrayList['Group'] = None
choices: ArrayList['Choice'] = None
sequences: ArrayList[Sequence] = None
max_occurs: int = 1
min_occurs: int = 1
class xsdata.models.elements.Group(id, prefix, nsmap, index, annotation, name, ref, all, choice, sequence, max_occurs=1, min_occurs=1)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.OccurrencesMixin, xsdata.models.mixins.NamedField

The group element is used to define a group of elements to be used in complex type definitions.

Reference: https://www.w3schools.com/xml/el_group.asp.

name: Optional[str] = None
ref: Optional[str] = None
all: Optional[All] = None
choice: Optional[Choice] = None
sequence: Optional[Sequence] = None
max_occurs: int = 1
min_occurs: int = 1
property extends
Return type

Optional[str]

class xsdata.models.elements.Extension(id, prefix, nsmap, index, annotation, base, group, all, choice, sequence, any_attribute, attributes=<factory>, attribute_groups=<factory>)[source]

Bases: xsdata.models.elements.AnnotationBase

The extension element extends an existing simpleType or complexType element.

Reference: https://www.w3schools.com/xml/el_extension.asp.

base: str = None
group: Optional[Group] = None
all: Optional[All] = None
choice: Optional[Choice] = None
sequence: Optional[Sequence] = None
any_attribute: Optional[AnyAttribute] = None
attributes: ArrayList[Attribute] = None
attribute_groups: ArrayList[AttributeGroup] = None
property extends
Return type

str

class xsdata.models.elements.RestrictionType(id, prefix, nsmap, index, annotation)[source]

Bases: xsdata.models.elements.AnnotationBase

The restriction element defines restrictions on a simpleType, simpleContent, or complexContent definition.

XSD Element reference

: Reference: https://www.w3schools.com/xml/el_restriction.asp.

annotation = None
class xsdata.models.elements.Enumeration(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType, xsdata.models.mixins.TypedField, xsdata.models.mixins.NamedField, xsdata.models.mixins.RestrictedField

Defines a list of acceptable values.

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: str = None
property is_attribute
Return type

bool

property real_type
property real_name
property default
get_restrictions()[source]
class xsdata.models.elements.FractionDigits(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies the maximum number of decimal places allowed. Must be equal to or greater than zero.

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: int = None
class xsdata.models.elements.Length(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies the exact number of characters or list items allowed. Must be equal to or greater than zero.

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: int = None
class xsdata.models.elements.MaxExclusive(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies the upper bounds for numeric values (the value must be less than this value)

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: float = None
class xsdata.models.elements.MaxInclusive(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies the upper bounds for numeric values (the value must be less than or equal to this value)

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: float = None
class xsdata.models.elements.MaxLength(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero.

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: float = None
class xsdata.models.elements.MinExclusive(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: float = None
class xsdata.models.elements.MinInclusive(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies the lower bounds for numeric values (the value must be greater than this value)

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: float = None
class xsdata.models.elements.MinLength(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies the lower bounds for numeric values (the value must be greater than or equal to this value)

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: float = None
class xsdata.models.elements.Pattern(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Defines the exact sequence of characters that are acceptable.

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: str = None
class xsdata.models.elements.TotalDigits(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies the exact number of digits allowed. Must be greater than zero.

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: int = None
class xsdata.models.elements.WhiteSpace(id, prefix, nsmap, index, annotation, value)[source]

Bases: xsdata.models.elements.RestrictionType

Specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled.

Schema Facet: Reference: https://www.w3schools.com/xml/schema_facets.asp.

value: str = None
class xsdata.models.elements.Restriction(id, prefix, nsmap, index, annotation, base, group, all, choice, sequence, any_attribute, min_exclusive, min_inclusive, min_length, max_exclusive, max_inclusive, max_length, total_digits, fraction_digits, length, white_space, pattern, simple_type, enumerations=<factory>, attributes=<factory>, attribute_groups=<factory>)[source]

Bases: xsdata.models.mixins.RestrictedField, xsdata.models.elements.AnnotationBase, xsdata.models.mixins.TypedField, xsdata.models.mixins.NamedField

The restriction element defines restrictions on a simpleType, simpleContent, or complexContent definition.

XSD Element reference

: Reference: https://www.w3schools.com/xml/el_restriction.asp.

VALUE_FIELDS = ('min_exclusive', 'min_inclusive', 'min_length', 'max_exclusive', 'max_inclusive', 'max_length', 'total_digits', 'fraction_digits', 'length', 'white_space', 'pattern')
CONTAINER_FIELDS = ('group', 'all', 'choice', 'sequence', 'any_attribute', 'attributes', 'attribute_groups', 'enumerations')
base: str = None
group: Optional[Group] = None
all: Optional[All] = None
choice: Optional[Choice] = None
sequence: Optional[Sequence] = None
any_attribute: Optional[AnyAttribute] = None
min_exclusive: Optional[MinExclusive] = None
min_inclusive: Optional[MinInclusive] = None
min_length: Optional[MinLength] = None
max_exclusive: Optional[MaxExclusive] = None
max_inclusive: Optional[MaxInclusive] = None
max_length: Optional[MaxLength] = None
total_digits: Optional[TotalDigits] = None
fraction_digits: Optional[FractionDigits] = None
length: Optional[Length] = None
white_space: Optional[WhiteSpace] = None
pattern: Optional[Pattern] = None
simple_type: Optional[SimpleType] = None
enumerations: ArrayList[Enumeration] = None
attributes: ArrayList[Attribute] = None
attribute_groups: ArrayList[AttributeGroup] = None
property is_attribute
Return type

bool

property real_type
Return type

Optional[str]

property real_name
Return type

str

property extends
Return type

Optional[str]

get_restrictions()[source]
Return type

Dict[str, Any]

class xsdata.models.elements.SimpleContent(id, prefix, nsmap, index, annotation, restriction, extension)[source]

Bases: xsdata.models.elements.AnnotationBase

The simpleContent element contains extensions or restrictions on a text- only complex type or on a simple type as content and contains no elements.

XSD Element reference

: Reference: https://www.w3schools.com/xml/el_simplecontent.asp.

restriction: Optional[Restriction] = None
extension: Optional[Extension] = None
class xsdata.models.elements.ComplexContent(id, prefix, nsmap, index, annotation, restriction, extension, mixed=False)[source]

Bases: xsdata.models.elements.SimpleContent

The complexContent element defines extensions or restrictions on a complex type that contains mixed content or elements only.

XSD Element reference

: Reference: https://www.w3schools.com/xml/el_complexcontent.asp.

mixed: bool = False
class xsdata.models.elements.ComplexType(id, prefix, nsmap, index, annotation, name, block, final, simple_content, complex_content, group, all, choice, sequence, any_attribute, attributes=<factory>, attribute_groups=<factory>, abstract=False, mixed=False)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.NamedField

The complexType element defines a complex type. A complex type element is an XML element that contains other elements and/or attributes.

XSD Element reference

: Reference: https://www.w3schools.com/xml/el_complextype.asp.

name: Optional[str] = None
block: Optional[str] = None
final: Optional[str] = None
simple_content: Optional[SimpleContent] = None
complex_content: Optional[ComplexContent] = None
group: Optional[Group] = None
all: Optional[All] = None
choice: Optional[Choice] = None
sequence: Optional[Sequence] = None
any_attribute: Optional[AnyAttribute] = None
attributes: ArrayList[Attribute] = None
attribute_groups: ArrayList[AttributeGroup] = None
abstract: bool = False
mixed: bool = False
class xsdata.models.elements.Field(id, prefix, nsmap, index, annotation, xpath)[source]

Bases: xsdata.models.elements.AnnotationBase

Reference: https://www.w3schools.com/xml/el_field.asp.

xpath: str = None
class xsdata.models.elements.Selector(id, prefix, nsmap, index, annotation, xpath)[source]

Bases: xsdata.models.elements.Field

The field element specifies an XPath expression that specifies the value used to define an identity constraint.

Reference: https://www.w3schools.com/xml/el_selector.asp.

xpath = None
class xsdata.models.elements.Unique(id, prefix, nsmap, index, annotation, name, selector, field)[source]

Bases: xsdata.models.elements.AnnotationBase

The unique element defines that an element or an attribute value must be unique within the scope. The unique element MUST contain the following (in order):

  • one and only one selector element (contains an XPath expression that specifies the set of elements across which the values specified by field must be unique)

  • one or more field elements (contains an XPath expression that specifies the values that must be unique for the set of elements specified by the selector element)

Reference: https://www.w3schools.com/xml/el_unique.asp.

name: str = None
selector: Optional[Selector] = None
field: Optional[Field] = None
class xsdata.models.elements.Key(id, prefix, nsmap, index, annotation, name, selector, fields=<factory>)[source]

Bases: xsdata.models.elements.AnnotationBase

Reference: https://www.w3schools.com/xml/el_key.asp.

name: str = None
selector: Optional[Selector] = None
fields: ArrayList[Selector] = None
class xsdata.models.elements.Keyref(id, prefix, nsmap, index, annotation, name, refer, selector, fields=<factory>)[source]

Bases: xsdata.models.elements.AnnotationBase

The key element specifies an attribute or element value as a key (unique, non-nullable, and always present) within the containing element in an instance document.

The key element MUST contain the following (in order):
  • one and only one selector element (contains an XPath expression that specifies the set of elements across which the values specified by field must be unique)

  • one or more field elements (contains an XPath expression that specifies the values that must be unique for the set of elements specified by the selector element)

Reference: https://www.w3schools.com/xml/el_keyref.asp.

name: str = None
refer: str = None
selector: Optional[Selector] = None
fields: ArrayList[Selector] = None
class xsdata.models.elements.Element(id, prefix, nsmap, index, annotation, name, ref, type, substitution_group, default, fixed, form, block, final, simple_type, complex_type, uniques=<factory>, keys=<factory>, keyrefs=<factory>, min_occurs=1, max_occurs=1, nillable=False, abstract=False)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.TypedField, xsdata.models.mixins.NamedField, xsdata.models.mixins.OccurrencesMixin

The element element defines an element.

Reference: https://www.w3schools.com/xml/el_element.asp.

name: str = None
id: Optional[str] = None
ref: Optional[str] = None
type: Optional[str] = None
substitution_group: Optional[str] = None
default: Optional[str] = None
fixed: Optional[str] = None
form: Optional[FormType] = None
block: Optional[List] = None
final: Optional[List] = None
simple_type: Optional[SimpleType] = None
complex_type: Optional[ComplexType] = None
uniques: ArrayList[Unique] = None
keys: ArrayList[Key] = None
keyrefs: ArrayList[Keyref] = None
min_occurs: int = 1
max_occurs: int = 1
nillable: bool = False
abstract: bool = False
property is_attribute
Return type

bool

property real_type
Return type

Optional[str]

get_restrictions()[source]
Return type

Dict[str, Any]

class xsdata.models.elements.Any(id, prefix, nsmap, index, annotation, namespace, process_contents, max_occurs=1, min_occurs=1)[source]

Bases: xsdata.models.elements.AnnotationBase, xsdata.models.mixins.OccurrencesMixin

The any element enables the author to extend the XML document with elements not specified by the schema.

Reference: https://www.w3schools.com/xml/el_any.asp.

namespace: Optional[str] = None
process_contents: Optional[ProcessType] = None
annotation: Optional[Annotation] = None
max_occurs: int = 1
min_occurs: int = 1
class xsdata.models.elements.Import(id, prefix, nsmap, index, annotation, namespace, schema_location)[source]

Bases: xsdata.models.elements.AnnotationBase

The import element is used to add multiple schemas with different target namespace to a document.

Reference: https://www.w3schools.com/xml/el_import.asp.

namespace: Optional[str] = None
schema_location: Optional[str] = None
class xsdata.models.elements.Include(id, prefix, nsmap, index, annotation, schema_location)[source]

Bases: xsdata.models.elements.AnnotationBase

The include element is used to add multiple schemas with the same target namespace to a document.

Reference: https://www.w3schools.com/xml/el_include.asp.

schema_location: str = None
property namespace
class xsdata.models.elements.Notation(id, prefix, nsmap, index, annotation, name, public, system)[source]

Bases: xsdata.models.elements.AnnotationBase

The notation element describes the format of non-XML data within an XML document.

Reference: https://www.w3schools.com/xml/el_notation.asp.

name: str = None
public: str = None
system: Optional[str] = None
class xsdata.models.elements.Redefine(id, prefix, nsmap, index, annotation, schema_location, simple_type, complex_type, group, attribute_group)[source]

Bases: xsdata.models.elements.AnnotationBase

The redefine element redefines simple and complex types, groups, and attribute groups from an external schema.

Reference: https://www.w3schools.com/xml/el_redefine.asp.

schema_location: str = None
simple_type: Optional[SimpleType] = None
complex_type: Optional[ComplexType] = None
group: Optional[Group] = None
attribute_group: Optional[AttributeGroup] = None
class xsdata.models.elements.Schema(id, prefix, nsmap, index, annotation, target, block_default, final_default, target_namespace, version, xmlns, location=None, element_form_default=<FormType.UNQUALIFIED: 'unqualified'>, attribute_form_default=<FormType.UNQUALIFIED: 'unqualified'>, includes=<factory>, imports=<factory>, redefines=<factory>, annotations=<factory>, simple_types=<factory>, complex_types=<factory>, groups=<factory>, attribute_groups=<factory>, elements=<factory>, attributes=<factory>, notations=<factory>)[source]

Bases: xsdata.models.elements.AnnotationBase

The schema element defines the root element of a schema.

Reference: https://www.w3schools.com/xml/el_schema.asp.

target: Optional[str] = None
block_default: Optional[str] = None
final_default: Optional[str] = None
target_namespace: Optional[str] = None
version: Optional[str] = None
xmlns: Optional[str] = None
location: Optional[pathlib.Path] = None
element_form_default: xsdata.models.enums.FormType = 'unqualified'
attribute_form_default: xsdata.models.enums.FormType = 'unqualified'
includes: ArrayList[Include] = None
imports: ArrayList[Import] = None
redefines: ArrayList[Redefine] = None
annotations: ArrayList[Annotation] = None
simple_types: ArrayList[SimpleType] = None
complex_types: ArrayList[ComplexType] = None
groups: ArrayList[Group] = None
attribute_groups: ArrayList[AttributeGroup] = None
elements: ArrayList[Element] = None
attributes: ArrayList[Attribute] = None
notations: ArrayList[Notation] = None
sub_schemas()[source]
Return type

Iterator[Union[Import, Include]]

property module
property target_prefix