xsdata.reducer module¶
-
class
xsdata.reducer.
ClassReducer
(common_types=<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.
-
common_types
: Dict[str, Class] = None¶
-
process
(schema, classes)[source]¶ Process class list in steps.
- Steps:
Separate common/enumerations from class list
Add all common/enumerations to registry
Flatten the current common types
Flatten the generation types
-
add_common_types
(classes, namespace)[source]¶ Add class to the common types registry with its qualified name with the target namespace.
-
find_common_type
(name, nsmap)[source]¶ Find a common type by the qualified named with the namespace prefix.
-
flatten_class
(item, nsmap)[source]¶ Flatten class traits from the common types registry.
- Steps:
Parent classes
Attributes
Inner classes
-
flatten_extension
(item, extension, nsmap)[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.
-