Package pyxb :: Package binding :: Module basis :: Class complexTypeDefinition
[hide private]
[frames] | no frames]

Class complexTypeDefinition

source code

                    object --+            
                             |            
                       cscRoot --+        
                                 |        
     utils.utility.Locatable_mixin --+    
                                     |    
                    _TypeBinding_mixin --+
                                         |
                            object --+   |
                                     |   |
utils.utility._DeconflictSymbols_mixin --+
                                         |
                        object --+       |
                                 |       |
                           cscRoot --+   |
                                     |   |
                  _DynamicCreate_mixin --+
                                         |
                                        complexTypeDefinition
Known Subclasses:

Base for any Python class that serves as the binding for an XMLSchema complexType.

Subclasses should define a class-level _AttributeMap variable which maps from the unicode tag of an attribute to the AttributeUse instance that defines it. Similarly, subclasses should define an _ElementMap variable.

Instance Methods [hide private]
 
wildcardAttributeMap(self)
Obtain access to wildcard attributes.
source code
 
wildcardElements(self)
Obtain access to wildcard elements.
source code
 
__init__(self, *args, **kw)
Create a new instance of this binding.
source code
 
__childrenForDOM(self)
Generate a list of children in the order in which they should be added to the parent when creating a DOM representation of this object.
source code
 
_validatedChildren(self)
Provide the child elements and non-element content in an order consistent with the content model.
source code
 
_symbolSet(self)
Return a map from content.ElementDeclaration instances to a list of values associated with that use.
source code
 
_validateAttributes(self) source code
 
_validateBinding_vx(self)
Override in subclasses for type-specific validation of instance content.
source code
 
_setAttribute(self, attr_en, value) source code
 
xsdConstraintsOK(self, location=None)
Validate the content against the simple type.
source code
 
orderedContent(self)
Return the element and non-element content of the instance in order.
source code
 
content(self)
Legacy interface for ordered content.
source code
 
value(self)
Return the value of the element.
source code
 
_resetContent(self, reset_elements=False)
Reset the content of an element value.
source code
 
_resetAutomaton(self) source code
 
_automatonConfiguration(self)
For whitebox testing use only
source code
 
reset(self)
Reset the instance.
source code
 
append(self, value, **kw)
Add the value to the instance.
source code
 
_appendWildcardElement(self, value) source code
 
extend(self, value_list, _fallback_namespace=None, _from_xml=False, _location=None)
Invoke append for each value in the list, in turn.
source code
 
__setContent(self, value) source code
 
_addContent(self, wrapped_value) source code
 
_finalizeContentModel(self)
Inform content model that all additions have been provided.
source code
 
_postDOMValidate(self) source code
 
_setDOMFromAttributes(self, dom_support, element)
Add any appropriate attributes from this instance into the DOM element.
source code
 
_toDOM_csc(self, dom_support, parent)
Create a DOM element with the given tag holding the content of this instance.
source code

Inherited from _TypeBinding_mixin: __setattr__, toDOM, toxml, validateBinding

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
_AddElement(cls, element)
Method used by generated code to associate the element binding with a use in this type.
source code
 
_UseForTag(cls, tag, raise_if_fail=True)
Return the ElementDeclaration object corresponding to the element name.
source code
 
__WarnOnContent(cls) source code
 
_ElementBindingDeclForName(cls, element_name)
Determine what the given name means as an element in this type.
source code
 
_IsMixed(cls) source code
 
_IsSimpleTypeContent(cls)
CTDs with simple content are simple; other CTDs are not.
source code
 
_description(cls, name_only=False, user_documentation=True) source code

Inherited from _TypeBinding_mixin: Factory

Class Variables [hide private]
  _CT_EMPTY = 'EMPTY'
  _CT_SIMPLE = 'SIMPLE'
  _CT_MIXED = 'MIXED'
hash(x)
  _CT_ELEMENT_ONLY = 'ELEMENT_ONLY'
  _ContentTypeTag = None
hash(x)
  _TypeDefinition = None
Subclass of simpleTypeDefinition that corresponds to the type content.
  _HasWildcardElement = False
  _ElementMap = {}
Map from expanded names to ElementDeclaration instances.
  __wildcardAttributeMap = None
hash(x)
  __wildcardElements = None
hash(x)
  _ReservedSymbols = set(['Factory', 'append', 'content', 'exten...
There are no reserved symbols in the base class.
  _Automaton = None
hash(x)
  __content = None
hash(x)
  __NeedWarnOnContent = True
  __automatonConfiguration = None
hash(x)

Inherited from _TypeBinding_mixin: _validationConfig_

Properties [hide private]

Inherited from _TypeBinding_mixin (private): _validationConfig

Inherited from object: __class__

Method Details [hide private]

wildcardAttributeMap(self)

source code 

Obtain access to wildcard attributes.

The return value is None if this type does not support wildcard attributes. If wildcard attributes are allowed, the return value is a map from QNames to the unicode string value of the corresponding attribute.

To Do: The map keys should be namespace extended names rather than QNames, as the in-scope namespace may not be readily available to the user.

wildcardElements(self)

source code 

Obtain access to wildcard elements.

The return value is None if the content model for this type does not support wildcard elements. If wildcard elements are allowed, the return value is a list of values corresponding to conformant unrecognized elements, in the order in which they were encountered. If the containing binding was created from an XML document and enough information was present to determine the binding of the member element, the value is a binding instance. Otherwise, the value is the original DOM Element node.

__init__(self, *args, **kw)
(Constructor)

source code 

Create a new instance of this binding.

Arguments are used as transition values along the content model. Keywords are passed to the constructor of any simple content, or used to initialize attribute and element values whose id (not name) matches the keyword.

Parameters:
  • _dom_node (xml.dom.Element) - The node to use as the source of binding content.
  • _location - An optional instance of pyxb.utils.utility.Location showing the origin the binding. If None, a value from _dom_node is used if available.
  • _from_xml - See _TypeBinding_mixin.Factory
  • _finalize_content_model - If True the constructor invokes _TypeBinding_mixin._finalizeContentModel prior to return. The value defaults to False when content is assigned through keyword parameters (bypassing the content model) or neither a _dom_node nor positional element parameters have been provided, and to True in all other cases.
Overrides: object.__init__

_AddElement(cls, element)
Class Method

source code 

Method used by generated code to associate the element binding with a use in this type.

This is necessary because all complex type classes appear in the module prior to any of the element instances (which reference type classes), so the association must be formed after the element instances are available.

_UseForTag(cls, tag, raise_if_fail=True)
Class Method

source code 

Return the ElementDeclaration object corresponding to the element name.

Parameters:

__childrenForDOM(self)

source code 

Generate a list of children in the order in which they should be added to the parent when creating a DOM representation of this object.

Note: This is only used when pyxb.RequireValidWhenGenerating has disabled validation. Consequently, it may not generate valid XML.

_validatedChildren(self)

source code 

Provide the child elements and non-element content in an order consistent with the content model.

Returns a sequence of tuples representing a valid path through the content model where each transition corresponds to one of the member element instances within this instance. The tuple is a pair comprising the content.ElementDeclaration instance and the value for the transition.

If the content of the instance does not validate against the content model, an exception is raised.

Returns:
None or a list as described above.

_symbolSet(self)

source code 

Return a map from content.ElementDeclaration instances to a list of values associated with that use.

This is used as the set of symbols available for transitions when validating content against a model. Note that the original content.ElementUse that may have validated the assignment of the symbol to the content is no longer available, which may result in a different order being generated by the content model. Preservation of the original order mitigates this risk.

The value None is used to provide the wildcard members, if any.

If an element use has no associated values, it must not appear in the returned map.

Raises:

_validateBinding_vx(self)

source code 

Override in subclasses for type-specific validation of instance content.

Returns:
True if the instance validates
Raises:
  • pyxb.BatchContentValidationError - complex content does not match model
  • pyxb.SimpleTypeValueError - simple content fails to satisfy constraints
Overrides: _TypeBinding_mixin._validateBinding_vx
(inherited documentation)

xsdConstraintsOK(self, location=None)

source code 

Validate the content against the simple type.

Returns:
True if the content validates against its type.
Raises:

orderedContent(self)

source code 

Return the element and non-element content of the instance in order.

This must be a complex type with complex content. The return value is a list of the element and non-element content in a preferred order.

The returned list contains element and non-element content in the order which it was added to the instance. This may have been through parsing a document, constructing an instance using positional arguments, invoking the append or extend methods, or assigning directly to an instance attribute associated with an element binding.

Raises:
Notes:
  • Be aware that assigning directly to an element attribute does not remove any previous value for the element from the content list.
  • Be aware that element values directly appended to an instance attribute with list type (viz., that corresponds to an element that allows more than one occurrence) will not appear in the ordered content list.

    The order in the list may influence the generation of documents depending on pyxb.ValidationConfig values that apply to an instance. Non-element content is emitted immediately prior to the following element in this list. Any trailing non-element content is emitted after the last element in the content. The list should include all element content. Element content in this list that is not present within an element member of the binding instance may result in an error, or may be ignored.

  • The returned value is mutable, allowing the caller to change the order to be used.

content(self)

source code 

Legacy interface for ordered content.

This version does not accurately distinguish non-element content from element content that happens to have unicode type.

Deprecated: use orderedContent.

value(self)

source code 

Return the value of the element.

This must be a complex type with simple content. The returned value is expected to be an instance of some simpleTypeDefinition class.

Raises:

_resetContent(self, reset_elements=False)

source code 

Reset the content of an element value.

This is not a public method.

For simple types, this does nothing. For complex types, this clears the content array, removing all non-element content from the instance. It optionally also removes all element content.

Parameters:
  • reset_elements - If False (default) only the content array is cleared, which has the effect of removing any preference for element order when generating a document. If True, the element content stored within the binding is also cleared, leaving it with no content at all.
Overrides: _TypeBinding_mixin._resetContent
(inherited documentation)

reset(self)

source code 

Reset the instance.

This resets all element and attribute fields, and discards any recorded content. It resets the content model automaton to its initial state.

See Also: Manipulate the return value of orderedContent if your intent is to influence the generation of documents from the binding instance without changing its (element) content.

_ElementBindingDeclForName(cls, element_name)
Class Method

source code 

Determine what the given name means as an element in this type.

Normally, element_name identifies an element definition within this type. If so, the returned element_decl identifies that definition, and the element_binding is extracted from that use.

It may also be that the element_name does not appear as an element definition, but that it identifies a global element. In that case, the returned element_binding identifies the global element. If, further, that element is a member of a substitution group which does have an element definition in this class, then the returned element_decl identifies that definition.

If a non-None element_decl is returned, there will be an associated element_binding. However, it is possible to return a non-None element_binding, but None as the element_decl. In that case, the element_binding can be used to create a binding instance, but the content model will have to treat it as a wildcard.

Parameters:
  • element_name - The name of the element in this type, either an expanded name or a local name if the element has an absent namespace.
Returns:
( element_binding, element_decl )

append(self, value, **kw)

source code 

Add the value to the instance.

The value should be a DOM node or other value that is or can be converted to a binding instance, or a string if the instance allows mixed content. The value must be permitted by the content model.

Raises:

_finalizeContentModel(self)

source code 

Inform content model that all additions have been provided.

This is used to resolve any pending non-determinism when the content of an element is provided through a DOM assignment or through positional arguments in a constructor.

Overrides: _TypeBinding_mixin._finalizeContentModel
(inherited documentation)

_postDOMValidate(self)

source code 
Overrides: _TypeBinding_mixin._postDOMValidate

_toDOM_csc(self, dom_support, parent)

source code 

Create a DOM element with the given tag holding the content of this instance.

Overrides: _TypeBinding_mixin._toDOM_csc

_IsSimpleTypeContent(cls)
Class Method

source code 

CTDs with simple content are simple; other CTDs are not.

Overrides: _TypeBinding_mixin._IsSimpleTypeContent

Class Variable Details [hide private]

_TypeDefinition

Subclass of simpleTypeDefinition that corresponds to the type content. Only valid if _ContentTypeTag is _CT_SIMPLE

Value:
None

_ReservedSymbols

There are no reserved symbols in the base class.

Value:
set(['Factory',
     'append',
     'content',
     'extend',
     'orderedContent',
     'property',
     'reset',
     'toDOM',
...