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

Class _TypeBinding_mixin

source code

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

Instance Methods [hide private]
 
_setValidationConfig(self, validation_config)
Set the validation configuration for this instance.
source code
 
__getValidationConfig(self)
The pyxb.ValidationConfig instance that applies to this instance.
source code
 
_performValidation(self)
Determine whether the content model should be validated for this instance.
source code
 
__setattr__(self, name, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
_namespaceContext(self)
Return a namespace context associated with the binding instance.
source code
 
_setNamespaceContext(self, namespace_context)
Associate a namespace context with the binding instance.
source code
 
_setElement(self, elt)
Associate an element binding with the instance.
source code
 
_element(self)
Return a pyxb.binding.basis.element associated with the binding instance.
source code
 
_isNil(self)
Indicate whether this instance is nil.
source code
 
_setIsNil(self, nil=True)
Set the xsi:nil property of the instance.
source code
 
_resetContent(self, reset_elements=False)
Reset the content of an element value.
source code
 
__checkNilCtor(self, args) source code
 
_constructedWithValue(self) source code
 
__init__(self, *args, **kw)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_postFactory_vx(cls, state)
Method invoked prior to leaving the Factory method.
source code
 
_substitutesFor(self, element) source code
 
_setAttributesFromKeywordsAndDOM(self, kw, dom_node)
Invoke self._setAttribute based on node attributes and keywords.
source code
xml.dom.Document
toDOM(self, bds=None, parent=None, element_name=None)
Convert this instance to a DOM node.
source code
 
toxml(self, encoding=None, bds=None, root_only=False)
Shorthand to get the object as an XML document.
source code
 
_toDOM_csc(self, dom_support, parent) source code
 
_validateBinding_vx(self)
Override in subclasses for type-specific validation of instance content.
source code
 
validateBinding(self)
Check whether the binding content matches its content model.
source code
 
_finalizeContentModel(self)
Inform content model that all additions have been provided.
source code
 
_postDOMValidate(self) source code
 
_diagnosticName(self)
The best name available for this instance in diagnostics.
source code
 
_TypeBinding_mixin__checkNilCtor(self, args) source code
 
_TypeBinding_mixin__getValidationConfig(self)
The pyxb.ValidationConfig instance that applies to this instance.
source code

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

Class Methods [hide private]
 
_SetValidationConfig(cls, validation_config)
Set the validation configuration for this class.
source code
 
_GetValidationConfig(cls)
The pyxb.ValidationConfig instance that applies to this class.
source code
 
_PerformValidation(cls)
Determine whether the content model should be validated for this class.
source code
 
_PreFactory_vx(cls, args, kw)
Method invoked upon entry to the Factory method.
source code
 
Factory(cls, *args, **kw)
Provide a common mechanism to create new instances of this type.
source code
 
_IsUrType(cls)
Return True iff this is the ur-type.
source code
 
_RequireXSIType(cls, value_type) source code
 
_CompatibleValue(cls, value, **kw)
Return a variant of the value that is compatible with this type.
source code
 
_IsSimpleTypeContent(cls)
Return True iff the content of this binding object is a simple type.
source code
 
__AttributesFromDOM(cls, node) source code
 
_Name(cls)
Return the best descriptive name for the type of the instance.
source code
 
_TypeBinding_mixin__AttributesFromDOM(cls, node) source code
Class Variables [hide private]
  _validationConfig_ = pyxb.GlobalValidationConfig
  _ExpandedName = None
The expanded name of the component.
  _XSDLocation = None
Where the definition can be found in the originating schema.
  _ReservedSymbols = set(['Factory', 'property', 'toDOM', 'toxml...
  _PyXBFactoryKeywords = ('_dom_node', '_fallback_namespace', '_...
Keywords that are interpreted by __new__ or __init__ in one or more classes in the PyXB type hierarchy.
  _Abstract = False
  __namespaceContext = None
hash(x)
  __element = None
hash(x)
  __xsiNil = None
hash(x)
  __constructedWithValue = False
  __WarnedUnassociatedElement = False
  _AttributeWildcard = None
hash(x)
  _AttributeMap = {}
Map from expanded names to AttributeUse instances.
  _TypeBinding_mixin__WarnedUnassociatedElement = False
  _TypeBinding_mixin__constructedWithValue = False
  _TypeBinding_mixin__element = None
hash(x)
  _TypeBinding_mixin__namespaceContext = None
hash(x)
  _TypeBinding_mixin__xsiNil = None
hash(x)
Properties [hide private]
  _validationConfig
The pyxb.ValidationConfig instance that applies to this instance.

Inherited from object: __class__

Method Details [hide private]

_GetValidationConfig(cls)
Class Method

source code 

The pyxb.ValidationConfig instance that applies to this class.

By default this will reference pyxb.GlobalValidationConfig.

__getValidationConfig(self)

source code 

The pyxb.ValidationConfig instance that applies to this instance.

By default this will reference the class value from _GetValidationConfig, which defaults to pyxb.GlobalValidationConfig.

_PerformValidation(cls)
Class Method

source code 

Determine whether the content model should be validated for this class.

In the absence of context, this returns True iff both binding and document validation are in force.

Deprecated: use _GetValidationConfig and check specific requirements.

_performValidation(self)

source code 

Determine whether the content model should be validated for this instance.

In the absence of context, this returns True iff both binding and document validation are in force.

Deprecated: use _validationConfig and check specific requirements.

__setattr__(self, name, value)

source code 

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__
(inherited documentation)

_namespaceContext(self)

source code 

Return a namespace context associated with the binding instance.

This will return None unless something has provided a context to the instance. Context is provided when instances are generated by the DOM and SAX-based translators.

_setElement(self, elt)

source code 

Associate an element binding with the instance.

Since the value of a binding instance reflects only its content, an associated element is necessary to generate an XML document or DOM tree.

Parameters:
  • elt - the pyxb.binding.basis.element instance associated with the value. This may be None when disassociating a value from a specific element.

_element(self)

source code 

Return a pyxb.binding.basis.element associated with the binding instance.

This will return None unless an element has been associated. Constructing a binding instance using the element instance will add this association.

_isNil(self)

source code 

Indicate whether this instance is nil.

The value is set by the DOM and SAX parsers when building an instance from a DOM element with xsi:nil set to true.

Returns:
None if the element used to create the instance is not nillable. If it is nillable, returns True or False depending on whether the instance itself is nil.

_setIsNil(self, nil=True)

source code 

Set the xsi:nil property of the instance.

Parameters:
  • nil - True if the value of xsi:nil should be true, False if the value of xsi:nil should be false.
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.

Note: This is not the same thing as complexTypeDefinition.reset, which unconditionally resets attributes and element and non-element content.

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

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

_PreFactory_vx(cls, args, kw)
Class Method

source code 

Method invoked upon entry to the Factory method.

This method is entitled to modify the keywords array. It can also return a state value which is passed to _postFactory_vx.

_postFactory_vx(cls, state)

source code 

Method invoked prior to leaving the Factory method.

This is an instance method, and is given the state that was returned by _PreFactory_vx.

Factory(cls, *args, **kw)
Class Method

source code 

Provide a common mechanism to create new instances of this type.

The class constructor won't do, because you can't create instances of union types.

This method may be overridden in subclasses (like STD_union). Pre- and post-creation actions can be customized on a per-class instance by overriding the _PreFactory_vx and _postFactory_vx methods.

Parameters:
  • _dom_node - If provided, the value must be a DOM node, the content of which will be used to set the value of the instance.
  • _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 - If True, the input must be either a DOM node or a unicode string comprising a lexical representation of a value. This is a further control on _apply_whitespace_facet and arises from cases where the lexical and value representations cannot be distinguished by type. The default value is True iff _dom_node is not None.
  • _apply_whitespace_facet - If True and this is a simpleTypeDefinition with a whiteSpace facet, the first argument will be normalized in accordance with that facet prior to invoking the parent constructor. The value is always True if text content is extracted from a _dom_node, and otherwise defaults to the defaulted value of _from_xml.
  • _validate_constraints - If True, any constructed value is checked against constraints applied to the union as well as the member type.
  • _require_value - If False (default), it is permitted to create a value without an initial value. If True and no initial value was provided, causes pyxb.SimpleContentAbsentError to be raised. Only applies to simpleTypeDefinition instances; this is used when creating values from DOM nodes.

_IsUrType(cls)
Class Method

source code 

Return True iff this is the ur-type.

The only ur-type is {http://www.w3.org/2001/XMLSchema}anyType. The implementation of this method is overridden for pyxb.binding.datatypes.anyType.

_CompatibleValue(cls, value, **kw)
Class Method

source code 

Return a variant of the value that is compatible with this type.

Compatibility is defined relative to the type definition associated with the element. The value None is always compatible. If value has a Python type (e.g., int) that is a superclass of the required _TypeBinding_mixin class (e.g., xs:byte), value is used as a constructor parameter to return a new instance of the required type. Note that constraining facets are applied here if necessary (e.g., although a Python int with value 500 is type-compatible with xs:byte, it is outside the value space, and compatibility will fail).

Parameters:
  • _convert_string_values - If True (default) and the incoming value is a string, an attempt will be made to form a compatible value by using the string as a constructor argument to the this class. This flag is set to False when testing automaton transitions.
Raises:

_IsSimpleTypeContent(cls)
Class Method

source code 

Return True iff the content of this binding object is a simple type.

This is true only for descendents of simpleTypeDefinition and instances of complexTypeDefinition that have simple type content.

_setAttributesFromKeywordsAndDOM(self, kw, dom_node)

source code 

Invoke self._setAttribute based on node attributes and keywords.

Though attributes can only legally appear in complexTypeDefinition instances, delayed conditional validation requires caching them in simpleTypeDefinition.

Parameters:
  • kw - keywords passed to the constructor. This map is mutated by the call: keywords corresponding to recognized attributes are removed.
  • dom_node - an xml.dom Node instance, possibly None

toDOM(self, bds=None, parent=None, element_name=None)

source code 

Convert this instance to a DOM node.

The name of the top-level element is either the name of the element instance associated with this instance, or the XML name of the type of this instance.

Parameters:
  • bds (pyxb.utils.domutils.BindingDOMSupport) - Support for customizing the generated document
  • parent (xml.dom.Element or None) - If None, a standalone document is created; otherwise, the created element is a child of the given element.
Returns: xml.dom.Document

toxml(self, encoding=None, bds=None, root_only=False)

source code 

Shorthand to get the object as an XML document.

If you want to set the default namespace, pass in a pre-configured bds.

Parameters:
  • encoding - The encoding to be used. See @xml.dom.Node.toxml() for a description of why you should always pass @'utf-8' here. Because this method follows the contract of the corresponding xml.dom.Node method, it does not automatically get the default PyXB output encoding.
  • bds - Optional pyxb.utils.domutils.BindingDOMSupport instance to use for creation. If not provided (default), a new generic one is created.

_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

validateBinding(self)

source code 

Check whether the binding content matches its content model.

Returns:
True if validation succeeds.
Raises:
  • pyxb.BatchContentValidationError - complex content does not match model
  • pyxb.SimpleTypeValueError - attribute or simple content fails to satisfy constraints

_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.

_Name(cls)
Class Method

source code 

Return the best descriptive name for the type of the instance.

This is intended to be a human-readable value used in diagnostics, and is the expanded name if the type has one, or the Python type name if it does not.

_diagnosticName(self)

source code 

The best name available for this instance in diagnostics.

If the instance is associated with an element, it is the element name; otherwise it is the best name for the type of the instance per _Name.

_TypeBinding_mixin__getValidationConfig(self)

source code 

The pyxb.ValidationConfig instance that applies to this instance.

By default this will reference the class value from _GetValidationConfig, which defaults to pyxb.GlobalValidationConfig.


Class Variable Details [hide private]

_ReservedSymbols

Value:
set(['Factory', 'property', 'toDOM', 'toxml', 'validateBinding'])

_PyXBFactoryKeywords

Keywords that are interpreted by __new__ or __init__ in one or more classes in the PyXB type hierarchy. All these keywords must be removed before invoking base Python __init__ or __new__.

Value:
('_dom_node',
 '_fallback_namespace',
 '_from_xml',
 '_apply_whitespace_facet',
 '_validate_constraints',
 '_require_value',
 '_nil',
 '_element',
...

_AttributeMap

Map from expanded names to AttributeUse instances. Non-empty only in complexTypeDefinition subclasses.

Value:
{}

Property Details [hide private]

_validationConfig

The pyxb.ValidationConfig instance that applies to this instance.

By default this will reference the class value from _GetValidationConfig, which defaults to pyxb.GlobalValidationConfig.

Get Method:
_TypeBinding_mixin__getValidationConfig(self) - The pyxb.ValidationConfig instance that applies to this instance.