xsdata.codegen.transformer module

class xsdata.codegen.transformer.SchemaTransformer(print, config)[source]

Bases: object

Orchestrate the code generation from a list of sources to the output format.

Parameters
  • print (bool) – Print to stdout the generated output

  • config (GeneratorConfig) – Generator configuration

print: bool
config: xsdata.models.config.GeneratorConfig
class_map: Dict[str, List[xsdata.codegen.models.Class]]
processed: List[str]
process_definitions(uri)[source]

Process a single wsdl resource.

Parameters

uri (str) –

process_schemas(uris)[source]

Run main processes.

Parameters

uris (List[str]) – list of uris to process

process_classes()[source]

Process the generated classes and write or print the final output.

process_schema(uri, namespace=None)[source]

Parse and convert schema to codegen models.

Avoid processing the same uri twice and fail silently if anything goes wrong with fetching and parsing the schema document.

Parameters
convert_schema(schema)[source]

Convert a schema instance to codegen classes and process imports to other schemas.

Parameters

schema (Schema) –

convert_definitions(definitions)[source]

Convert a definitions instance to codegen classes.

Parameters

definitions (Definitions) –

generate_classes(schema)[source]

Convert and return the given schema tree to classes.

Parameters

schema (Schema) –

Return type

List[Class]

classmethod parse_schema(uri, namespace)[source]

Parse the given schema uri and return the schema tree object.

Optionally add the target namespace if the schema is included and is missing a target namespace.

Parameters
Return type

Optional[Schema]

parse_definitions(uri, namespace)[source]

Parse recursively the given wsdl uri and return the definitions tree object.

Raises

OSError – if it fails to load the definition uri.

Parameters
Return type

Definitions

classmethod load_resource(uri)[source]

Read and return the contents of the given uri.

Raises

OSError – if it fails during open/read .

Parameters

uri (str) –

Return type

bytes

analyze_classes(classes)[source]

Analyzer the given class list and simplify attributes and extensions.

Parameters

classes (List[Class]) –

Return type

List[Class]

count_classes(classes)[source]

Return a tuple of counters for the main and inner classes.

Parameters

classes (List[Class]) –

Return type

Tuple[int, int]

assign_packages()[source]

Group uris by common path and auto assign package names to all classes.

classmethod assign_package(classes, package)[source]

Assign the given package to all the classes and their inners.

Parameters