xsdata.codegen.builder module

class xsdata.codegen.builder.ClassBuilder(schema)[source]

Bases: object

Parameters

schema (Schema) –

schema: Schema = None
build()[source]

Generate classes from schema and redefined elements.

Return type

List[Class]

build_class(obj)[source]

Build and return a class instance.

Parameters

obj (ElementBase) –

Return type

Class

build_class_attributes(obj, target)[source]

Build the target class attributes from the given ElementBase children.

Parameters
build_class_extensions(obj, target)[source]

Build the item class extensions from the given ElementBase children.

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

AttrType

element_children(obj, restrictions=None)[source]

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

Parameters
Return type

Iterator[Tuple[ElementBase, 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 ns_map

  • qualified elements returns the schema target namespace

  • unqualified elements return an empty string

  • unqualified attributes return None

Parameters

obj (ElementBase) –

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.

Parameters
Return type

Iterator[Extension]

build_class_extension(target, name, index, restrictions)[source]
Parameters
  • target (Class) –

  • name (str) –

  • index (int) –

  • restrictions (Dict) –

Return type

Extension

build_class_attribute(target, obj, parent_restrictions)[source]

Generate and append an attribute target to the target class.

Parameters
build_class_attribute_types(target, obj)[source]

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

Parameters
Return type

List[AttrType]

build_inner_classes(obj)[source]

Find and convert anonymous types to a class instances.

Parameters

obj (ElementBase) –

Return type

Iterator[Class]