models
xsdata.codegen.models
CodegenModel
dataclass
Base codegen model.
Source code in xsdata/codegen/models.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
clone(**kwargs)
Return a deep cloned instance.
Source code in xsdata/codegen/models.py
40 41 42 43 |
|
swap(source)
Swap the instance attributes from the source instance.
Source code in xsdata/codegen/models.py
45 46 47 48 49 |
|
Restrictions
dataclass
Bases: CodegenModel
Class field validation restrictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_occurs | Optional[int] | The minimum number of occurrences | None |
max_occurs | Optional[int] | The maximum number of occurrences | None |
min_exclusive | Optional[str] | The lower exclusive bound for numeric values | None |
min_inclusive | Optional[str] | The lower inclusive bound for numeric values | None |
min_length | Optional[int] | The minimum length of characters or list items allowed | None |
max_exclusive | Optional[str] | The upper exclusive bound for numeric values | None |
max_inclusive | Optional[str] | The upper inclusive bound for numeric values | None |
max_length | Optional[int] | The max length of characters or list items allowed | None |
total_digits | Optional[int] | The exact number of digits allowed for numeric values | None |
fraction_digits | Optional[int] | The maximum number of decimal places allowed | None |
length | Optional[int] | The exact number of characters or list items allowed | None |
white_space | Optional[str] | Specifies how white space is handled | None |
pattern | Optional[str] | Defines the exact sequence of characters that are acceptable | None |
explicit_timezone | Optional[str] | Require or prohibit the time zone offset in date/time | None |
nillable | Optional[bool] | Specifies whether nil content is allowed | None |
sequence | Optional[int] | The sequence reference number of the attr | None |
tokens | Optional[bool] | Specifies whether the value needs tokenization | None |
format | Optional[str] | The output format used for byte and datetime types | None |
choice | Optional[int] | The choice reference number of the attr | None |
group | Optional[int] | The group reference number of the attr | None |
process_contents | Optional[str] | Specifies the content processed mode: strict, lax, skip | None |
path | list[tuple[str, int, int, int]] | The coded attr path in the source document | list() |
Source code in xsdata/codegen/models.py
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 |
|
is_list
property
Return whether the max occurs larger than one.
is_optional
property
Return whether the min occurs is zero.
is_prohibited
property
Return whether the max occurs is zero.
merge(source)
Update properties from another instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | Restrictions | The source instance to merge properties from | required |
Source code in xsdata/codegen/models.py
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 |
|
asdict(types=None)
Return the initialized only properties as a dictionary.
Skip None or implied values, and optionally use the attribute types to convert relevant options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
types | Optional[list[type]] | An optional list of attr python types | None |
Returns:
Type | Description |
---|---|
dict | A key-value of map of the attr restrictions for generation. |
Source code in xsdata/codegen/models.py
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 |
|
from_element(element)
classmethod
Static constructor from a xsd model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element | ElementBase | A element base instance. | required |
Returns:
Type | Description |
---|---|
Restrictions | The new restrictions instance |
Source code in xsdata/codegen/models.py
206 207 208 209 210 211 212 213 214 215 216 |
|
AttrType
dataclass
Bases: CodegenModel
Class field typing information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qname | str | The namespace qualified name | required |
alias | Optional[str] | The type alias | None |
reference | int | The type reference number | 0 |
native | bool | Specifies if it's python native type | False |
forward | bool | Specifies if it's a forward reference | False |
circular | bool | Specifies if it's a circular reference | False |
substituted | bool | Specifies if it has been processed for substitution groups | False |
Source code in xsdata/codegen/models.py
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 |
|
datatype
property
Return the datatype instance if native, none otherwise.
name
property
Shortcut for qname local name.
is_dependency(allow_circular)
Return whether this type is a dependency.
The type must a reference to a user type, not a forward reference and not a circular unless if it's allowed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allow_circular | bool | Allow circular references as dependencies | required |
Returns:
Type | Description |
---|---|
bool | The bool result/ |
Source code in xsdata/codegen/models.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
Attr
dataclass
Bases: CodegenModel
Class field model representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag | str | The xml tag that produced this attr | required |
name | str | The final attr name | required |
local_name | str | The original attr name | '' |
wrapper | Optional[str] | The wrapper element name | None |
index | int | The index position of this attr in the class | int() |
default | Optional[str] | The default value | None |
fixed | bool | Specifies if the default value is fixed | False |
mixed | bool | Specifies if the attr supports mixed content | False |
types | list[AttrType] | The attr types list | list() |
choices | list[Attr] | The attr choice list | list() |
namespace | Optional[str] | The attr namespace | None |
help | Optional[str] | The attr help text | None |
restrictions | Restrictions | The attr restrictions instance | Restrictions() |
parent | Optional[str] | The parent class qualified name of the attr | None |
substitution | Optional[str] | The substitution group this attr belongs to | None |
Source code in xsdata/codegen/models.py
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 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
|
key
property
Generate a key for this attr.
Concatenate the tag/namespace/local_name. This key is used to find duplicates, it's not supposed to be unique.
Returns:
Type | Description |
---|---|
str | The unique key for this attr. |
qname
property
Return the fully qualified name of the attr.
is_attribute
property
Return whether this attr represents a xml attribute node.
is_element
property
Return whether this attr represents a xml element.
is_enumeration
property
Return whether this attr an enumeration member.
is_dict
property
Return whether this attr is derived from xs:anyAttribute.
is_factory
property
Return whether this attribute is a list of items or a mapping.
is_forward_ref
property
Return whether any attr types is a forward or circular reference.
is_circular_ref
property
Return whether any attr types is a circular reference.
is_group
property
Return whether this attr is a reference to a group class.
is_list
property
Return whether this attr requires a list of values.
is_prohibited
property
Return whether this attr is prohibited.
is_nameless
property
Return whether this attr is a real xml node.
is_nillable
property
Return whether this attr supports nil values.
is_optional
property
Return whether this attr is not required.
is_suffix
property
Return whether this attr is supposed to be generated last.
is_xsi_type
property
Return whether this attr represents a xsi:type attribute.
is_tokens
property
Return whether this attr supports token values.
is_wildcard
property
Return whether this attr supports any content.
is_any_type
property
Return whether this attr types support any content.
native_types
property
Return a list of all the builtin data types.
user_types
property
Yield an iterator of all the user defined types.
slug
property
Return the slugified name of the attr.
xml_type
property
Return the xml type this attribute is mapped to.
__post_init__()
Post init processing.
Source code in xsdata/codegen/models.py
306 307 308 309 310 311 312 |
|
get_native_types()
Yield an iterator of all the native attr types.
Source code in xsdata/codegen/models.py
445 446 447 448 449 450 |
|
can_be_restricted()
Return whether this attr can be restricted.
Source code in xsdata/codegen/models.py
452 453 454 |
|
Extension
dataclass
Bases: CodegenModel
Base class model representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag | str | The xml tag that produced this extension | required |
type | AttrType | The extension type | required |
restrictions | Restrictions | The extension restrictions instance | required |
Source code in xsdata/codegen/models.py
457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
Status
Bases: IntEnum
Class process status enumeration.
Source code in xsdata/codegen/models.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
|
Class
dataclass
Bases: CodegenModel
Class model representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qname | str | The namespace qualified name | required |
tag | str | The xml tag that produced this class | required |
location | str | The schema/document location uri | required |
mixed | bool | Specifies whether this class supports mixed content | False |
abstract | bool | Specifies whether this is an abstract class | False |
nillable | bool | Specifies whether this class supports nil content | False |
local_type | bool | Specifies if this class was an inner type at some point | False |
status | Status | The processing status of the class | RAW |
container | Optional[str] | The xml container of the class, schema, override, redefine | None |
package | Optional[str] | The designated package of the class | None |
module | Optional[str] | The designated module of the class | None |
namespace | Optional[str] | The class namespace | None |
help | Optional[str] | The help text | None |
meta_name | Optional[str] | The xml element name of the class | None |
default | Any | The default value | None |
fixed | bool | Specifies whether the default value is fixed | False |
substitutions | list[str] | The list of all the substitution groups this class belongs to | list() |
extensions | list[Extension] | The list of all the extension instances | list() |
attrs | list[Attr] | The list of all the attr instances | list() |
inner | list[Class] | The list of all the inner class instances | list() |
ns_map | dict | The namespace prefix-URI map | dict() |
parent | Optional[Class] | The parent outer class | None |
Source code in xsdata/codegen/models.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
|
name
property
Shortcut for the class local name.
slug
property
Return a slugified version of the class name.
ref
property
Return this id reference of this instance.
target_namespace
property
Return the class target namespace.
has_suffix_attr
property
Return whether it includes a suffix attr.
has_help_attr
property
Return whether at least one of attrs has help content.
is_element
property
Return whether this class represents a xml element.
is_enumeration
property
Return whether all attrs are enumeration members.
is_complex_type
property
Return whether this class represents a root/global class.
Global classes are the only classes that get generated by default.
is_group
property
Return whether this class is derived from a xs:group/attributeGroup.
is_nillable
property
Return whether this class represents a nillable xml element.
is_mixed
property
Return whether this class supports mixed content.
is_restricted
property
Return whether this class includes any restriction extensions.
is_service
property
Return whether this instance is derived from a wsdl:operation.
references
property
Yield all class object reference numbers.
target_module
property
Return the designated full module path.
Raises:
Type | Description |
---|---|
CodeGenerationError | if the target was not designated a package and module. |
dependencies(allow_circular=False)
Yields all class dependencies.
Omit circular and forward references by default.
Collect
- base classes
- attribute types
- attribute choice types
- recursively go through the inner classes
- Ignore inner class references
- Ignore native types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allow_circular | bool | Allow circular references | False |
Source code in xsdata/codegen/models.py
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
|
types()
Yields all class types.
Source code in xsdata/codegen/models.py
662 663 664 665 |
|
types_with_parents()
Yields all class types with their parent codegen instance.
Source code in xsdata/codegen/models.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
|
children()
Yield all codegen children.
Source code in xsdata/codegen/models.py
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
|
has_forward_ref()
Return whether this class has any forward references.
Source code in xsdata/codegen/models.py
705 706 707 708 709 710 711 712 713 714 |
|
parent_names()
Return the outer class names.
Source code in xsdata/codegen/models.py
716 717 718 719 720 721 722 723 724 |
|
Import
dataclass
Python import statement model representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qname | str | The qualified name of the imported class | required |
source | str | The absolute module path | required |
alias | Optional[str] | Specifies an alias to avoid naming conflicts | None |
Source code in xsdata/codegen/models.py
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
|
name
property
Return the name of the imported class.
slug
property
Return a slugified version of the imported class name.