xsdata.codegen.handlers.class_extension module

class xsdata.codegen.handlers.class_extension.ClassExtensionHandler(container)[source]

Bases: xsdata.codegen.mixins.HandlerInterface

Reduce class extensions by copying or creating new attributes.

Parameters

container (ContainerInterface) –

INCLUDES_NONE = 0
INCLUDES_SOME = 1
INCLUDES_ALL = 2
container: ContainerInterface = None
process(target)[source]
Parameters

target (Class) –

process_extension(target, extension)[source]
Parameters
classmethod process_native_extension(target, extension)[source]

Native type flatten extension handler, ignore enumerations.

Parameters
process_dependency_extension(target, extension)[source]
Parameters
classmethod process_simple_extension(source, target, ext)[source]

Simple flatten extension handler for common classes eg SimpleType, Restriction.

Steps:
  1. If target is source: drop the extension.

  2. If source is enumeration and target isn’t create default value attribute.

  3. If both source and target are enumerations copy all attributes.

  4. If both source and target are not enumerations copy all attributes.

  5. If target is enumeration: drop the extension.

Parameters
classmethod process_complex_extension(source, target, ext)[source]

Complex flatten extension handler for primary classes eg ComplexType, Element.

Drop extension when:
  • source includes all target attributes

Copy all attributes when:
  • source includes some of the target attributes

  • source has suffix attribute and target has at least one attribute

  • target has at least one suffix attribute

  • source or target class is abstract

Parameters
find_dependency(target, attr_type)[source]

Find dependency for the given extension type with priority.

Search priority: xs:SimpleType > xs:ComplexType

Parameters
Return type

Optional[Class]

classmethod compare_attributes(source, target)[source]

Compare the attributes of the two classes and return whether the source includes all, some or none of the target attributes.

Parameters
Return type

int

classmethod copy_extension_type(target, extension)[source]

Add the given extension type to all target attributes types and remove it from the target class extensions.

Parameters
classmethod create_default_attribute(item, extension)[source]

Add a default value field to the given class based on the extension type.

Parameters