xsdata.builder module

class xsdata.builder.ClassBuilder(schema, package)[source]

Bases: object

schema: Schema = None
package: str = None
build()[source]

Generate classes from schema and redefined elements.

Return type

List[Class]

build_class(obj)[source]

Build and return a class instance.

Return type

Class

build_class_attributes(obj, target)[source]

Build the target class attributes from the given ElementBase children.

build_class_extensions(obj, target)[source]

Build the item class extensions from the given ElementBase children.

build_data_type(target, name, index=0, forward_ref=False)[source]
Return type

AttrType

element_children(obj, restrictions=None)[source]

Recursively find and return all child elements that are qualified to be class attributes.

Return type

Iterator[Tuple[Union[Attribute, Element, Restriction, Enumeration, Union, List, SimpleType], Restrictions]]

element_namespace(obj)[source]

Return the target namespace for the given schema element.

In order:
  • elements/attributes with specific target namespace

  • prefixed elements returns the namespace from schema nsmap

  • qualified elements returns the schema target namespace

  • unqualified elements return an empty string

  • unqualified attributes return None

Return type

Optional[str]

children_extensions(obj, target)[source]

Recursively find and return all target’s Extension classes.

If the initial given obj has a type attribute include it in result.

Return type

Iterator[Extension]

build_class_extension(target, name, index, restrictions)[source]
build_class_attribute(target, obj, parent_restrictions)[source]

Generate and append an attribute target to the target class.

build_class_attribute_types(target, obj)[source]

Convert real type and anonymous inner elements to an attribute type list.

Return type

List[AttrType]

build_inner_class(obj)[source]

Find and convert anonymous types to a class instance.

Return type

Optional[Class]

static has_anonymous_class(obj)[source]

Check if the attribute element contains anonymous complex type.

Return type

bool

static has_anonymous_enumeration(obj)[source]

Check if the attribute element contains anonymous restriction with enumeration facet.

Return type

bool