xsdata.reducer module¶
-
class
xsdata.reducer.
ClassReducer
(common_types=<factory>, processed=<factory>, class_index=<factory>)[source]¶ Bases:
object
The purpose of this class is to minimize the number of generated classes because of excess verbosity in the given xsd schema and duplicate types.
-
schema
: Schema = None¶
-
common_types
: Dict[str, Class] = None¶
-
processed
: Dict = None¶
-
class_index
: Dict[str, List[Class]] = None¶
-
process
(schema, classes)[source]¶ Process class list in steps.
- Steps:
Merge redefined classes
Create a class qname index
Mark as abstract classes with the same qname
Flatten classes
Return a final class list for code generators.
-
fetch_classes_for_generation
()[source]¶ Return the qualified classes to continue for code generation.
The rest of the classes are stored as common types to be used later by the next schemas in the proccess.
- Qualifications:
not an abstract
type: element | complexType | simpleType with enumerations
-
mark_abstract_duplicate_classes
()[source]¶ Search for groups with more than one class and mark as abstract any complex type with the same name as an element.
-
flatten_class
(item)[source]¶ Flatten class traits from the common types registry.
- Steps:
Enum unions
Parent classes
Attributes
Inner classes
-
flatten_extension
(item, extension)[source]¶ If the extension class is found in the registry prepend it’s attributes to the given class.
The attribute list is deep cloned and each attribute type is prepended with the extension prefix if it isn’t a reference to another schema.
-