create_wrapper_fields
xsdata.codegen.handlers.create_wrapper_fields
CreateWrapperFields
Bases: RelativeHandlerInterface
Create wrapper fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container | ContainerInterface | The class container instance | required |
Source code in xsdata/codegen/handlers/create_wrapper_fields.py
8 9 10 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 |
|
process(target)
Process the given class attrs and choices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance | required |
Source code in xsdata/codegen/handlers/create_wrapper_fields.py
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 |
|
wrap_field(source, attr, inner)
classmethod
Create a wrapper field.
Clone the source attr and update its name, local name and wrapper attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | Attr | The source attr instance | required |
attr | Attr | The attr instance to wrap | required |
inner | bool | Specify if the source is from an inner class | required |
Source code in xsdata/codegen/handlers/create_wrapper_fields.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
find_source_attr(parent, attr)
Find the source type for the given attr type instance.
If it's a forward reference, look up the source in the parent class inners.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent | Class | The parent class instance | required |
attr | Attr | The attr instance to find a valid source attr | required |
Returns:
Type | Description |
---|---|
Tuple[bool, Optional[Attr]] | A tuple of whether the source attr is inner and the source attr. |
Source code in xsdata/codegen/handlers/create_wrapper_fields.py
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 |
|
validate_attr(attr)
classmethod
Validate if the attr can be converted to a wrapper field.
Rules
- Must be an element
- Must have only one user type
- The element can't be optional
- The element can't be a list element
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr | Attr | The attr instance to validate | required |
Returns:
Type | Description |
---|---|
bool | Whether the attr can be converted to a wrapper. |
Source code in xsdata/codegen/handlers/create_wrapper_fields.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
validate_source(source, namespace)
classmethod
Validate if the source class can be converted to a wrapper field.
Rules
- It must not have any extensions
- It must contain exactly one type
- It must be derived from a xs:element
- It must not be optional
- It must not be a forward reference
- The source attr namespace must match the namespace
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | Class | The source class instance to validate | required |
namespace | Optional[str] | The processing attr namespace | required |
Returns:
Type | Description |
---|---|
bool | Whether the source class can be converted to a wrapper. |
Source code in xsdata/codegen/handlers/create_wrapper_fields.py
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 |
|