add_attribute_substitutions
xsdata.codegen.handlers.add_attribute_substitutions
AddAttributeSubstitutions
Bases: RelativeHandlerInterface
Apply substitution attributes to the given class recursively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container | ContainerInterface | The class container instance | required |
Attributes:
Name | Type | Description |
---|---|---|
substitutions | Optional[dict[str, list[Attr]]] | Mapping of type names to attr values |
Source code in xsdata/codegen/handlers/add_attribute_substitutions.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
process(target)
Process the given class attrs for substitution groups.
This method will ignore attrs in the class derived from a xs:enumeration, xs:anyType and xs:any. If this is the first time we call the method, build the substitution map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
Source code in xsdata/codegen/handlers/add_attribute_substitutions.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
process_attribute(target, attr)
Add substitution attrs that refer to the attr type.
If the given attr is referenced in substitution groups clone all substitution attrs and place them bellow the original attr. Convert all the attrs of the group to repeatable choice elements.
Guard against multiple substitutions in case of xs:groups.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
attr | Attr | The source attr instance to check and process | required |
Source code in xsdata/codegen/handlers/add_attribute_substitutions.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
create_substitutions()
Build the substitutions mapping of type names to attr values.
The values are simple reference attrs that we can easily clone later on demand.
Source code in xsdata/codegen/handlers/add_attribute_substitutions.py
82 83 84 85 86 87 88 89 90 91 92 |
|
prepare_substituted(attr)
classmethod
Prepare the original attr for substitutions.
Effectively place the attr inside a xs:choice container with min occurs zero.
Source code in xsdata/codegen/handlers/add_attribute_substitutions.py
94 95 96 97 98 99 100 101 102 103 104 105 |
|
create_substitution(source)
classmethod
Create a reference attr to the source class qname.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | Class | The source class to reference | required |
Returns:
Type | Description |
---|---|
Attr | The reference to the source class attr. |
Source code in xsdata/codegen/handlers/add_attribute_substitutions.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|