Skip to content


The ResourceTransformer is the orchestrator of the code generation procedure.

graph LR
    A[Load Resources] --> B(Parse transfer objects)
    B --> C[Convert to classes]
    C --> D[Analyze classes]
    D--> E[Write Output]

Load Resource

The code generator accepts URIs indicating either local or remote file locations.

The resource type (xsd, wsdl, dtd, xml, json) is identified based on the file extension, if present. If the resource lacks an extension, the loader will attempt to locate specific syntax markings associated with the resource type.

If a resource cannot be accessed, a warning is issued, and the program continues its normal flow. In the case of circular imports, resources are loaded only once.

Parse transfer objects

A resource-specific parser is utilized to bind document information to transfer objects. Additionally, the parsers are responsible for assigning common values required for later analysis, such as locations, a namespace prefix-URI map, and common namespaces like xsi and xlink.

Convert to classes

A resource-specific parser is utilized to convert the transfer objects to codegen classes. These mappers encapsulate the pertinent logic detailing how the resource types should be interpreted.

Analyze classes

graph LR
    A[Validate classes] --> B(Process classes)
    B --> C[Validate class references]

Validate Classes

  • Remove types with unknown references
<xs:element name="root" ref="xs:missingOrUnknown"/>
  • Remove duplicate types: Keep the last definition
<xs:element name="root" ref="RootType"/>
<xs:element name="root" ref="RootType"/>
  • Remove duplicate overridden types:
<xs:override schemaLocation="over005a.xsd">
    <xs:attribute name="code" type="xs:date"/>
  • Merge redefined types:
<xs:redefine schemaLocation="schZ006.xsd">
    <xs:group name="GCustomDimProps">
            <xs:element name="DisplayInfo"  type="xs:unsignedInt"/>

API: xsdata.codegen.validator.ClassValidator

Analyze Classes

The classes are wrapped in a ClassContainer instance. It includes some easy finder methods and orchestrates flattening/filtering processes.

The process is divided into multiple steps and handlers per step. All classes have to pass through each step before next one starts. The order of the steps is very important!

Step: Ungroup

Step: Flatten

Step: Filer

Step: Sanitize

Step: Resolve

Step: Vacuum

Step: Finalize

Step: Designate