process_attributes_types
xsdata.codegen.handlers.process_attributes_types
ProcessAttributeTypes
Bases: RelativeHandlerInterface
Minimize class attrs complexity by filtering and flattening types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container | ContainerInterface | The container instance | required |
Attributes:
Name | Type | Description |
---|---|---|
dependencies | Dict | Class qname dependencies mapping |
Source code in xsdata/codegen/handlers/process_attributes_types.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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
process(target)
Process the given class attrs and their types.
Cascades class restrictions to class attrs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
27 28 29 30 31 32 33 34 35 36 37 |
|
process_types(target, attr)
Process every attr type and filter out duplicates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
attr | Attr | The attr instance | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
cascade_properties(target, attr)
classmethod
Cascade class properties to the attr if it's a text node.
Properties
- Default value
- Fixed flag
- Nillable flag
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
attr | Attr | The attr instance | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
process_type(target, attr, attr_type)
Process attr type.
Cases
- Attr type is a native xsd type
- Attr type is a forward reference (inner class)
- Attr type is a complex user defined type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
attr | Attr | The attr instance | required |
attr_type | AttrType | The attr type instance | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
process_native_type(attr, attr_type)
classmethod
Process native xsd types.
Cascade the datatype restrictions to the attr and also resets the type to a simple xsd:string if there is a pattern restriction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr | Attr | The attr instance | required |
attr_type | AttrType | The attr type instance | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
find_dependency(attr_type, tag)
Find the source type from the attr type and tag.
Avoid conflicts by selecting any matching type by qname and preferably
- Match the candidate object tag
- Match element again complexType
- Match non element and complexType
- Anything
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr_type | AttrType | The attr type instance | required |
tag | str | The xml tag name, e.g. Element, Attribute, ComplexType | required |
Returns:
Type | Description |
---|---|
Optional[Class] | The source class or None if no match is found |
Source code in xsdata/codegen/handlers/process_attributes_types.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
process_inner_type(target, attr, attr_type)
Process an attr type that depends on a simple inner type.
Skip If the source class is not simple type, or it's a circular reference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
attr | Attr | The attr instance | required |
attr_type | AttrType | The attr type instance | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
process_dependency_type(target, attr, attr_type)
Process an attr type that depends on any global type.
Strategies
- Reset absent types with a warning
- Copy format restriction from an enumeration
- Copy attribute properties from a simple type
- Set circular flag for the rest
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
attr | Attr | The attr instance | required |
attr_type | AttrType | The attr type instance | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
copy_attribute_properties(source, target, attr, attr_type)
classmethod
Replace the attr type with the types of the first attr in the source class.
Ignore enumerations and gracefully handle dump types with no attrs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | Class | The source class instance | required |
target | Class | The target class instance | required |
attr | Attr | The attr instance | required |
attr_type | AttrType | The attr type instance | required |
Raises:
Type | Description |
---|---|
AnalyzerValueError | if the source class has more than one attributes |
Source code in xsdata/codegen/handlers/process_attributes_types.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
reset_attribute_type(attr_type)
classmethod
Reset the attribute type to string.
The method will also unset the circular/forward flags, as native types only depend on python builtin types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr_type | AttrType | The attr type instance to reset | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
update_restrictions(attr, datatype)
classmethod
Helper method to copy the native datatype restriction to the attr.
Sets
- The format restriction, e.g. hexBinary, base64Binary
- The tokens flag for xs:NMTOKENS and xs:IDREFS
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr | Attr | The attr to update | required |
datatype | DataType | The datatype to extract the restrictions. | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
detect_lazy_namespace(source, target, attr)
classmethod
Set the attr namespace if the current is marked as lazy.
Cases
WSDL message part type can be an element, complex or simple type, we can't do the detection during the initial mapping to class objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | Class | The source class instance | required |
target | Class | The target class instance | required |
attr | Attr | The target class attr instance | required |
Source code in xsdata/codegen/handlers/process_attributes_types.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|