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]
 
__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, element)
Associate a pyxb.binding.basis.element 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)
Set the xsi:nil property of the instance.
source code
 
_resetContent(self) 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
 
_postDOMValidate(self) source code
 
_TypeBinding_mixin__checkNilCtor(self, args) source code

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

Class Methods [hide private]
 
_PerformValidation(cls)
Determine whether the content model should be validated.
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) source code
 
_TypeBinding_mixin__AttributesFromDOM(cls, node) source code
Class Variables [hide private]
  _ExpandedName = None
The expanded name of the component.
  _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]

Inherited from object: __class__

Method Details [hide private]

_PerformValidation(cls)
Class Method

source code 

Determine whether the content model should be validated.

Proper validation is not yet supported in PyXB. The low level binding material consults this function, but not always in a context where the direction of translation is clear. Conseequently, this method indicates that validation should be performed only when both generation and parsing validation are enabled.

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

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

source code 

Set the xsi:nil property of the instance.

Raises:

__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.
  • _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.
  • _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.MissingContentError 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:
  • pyxb.BadTypeValueError - if the value is not both type-consistent and value-consistent with the element's type.

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

validateBinding(self)

source code 

Check whether the binding content matches its content model.

Returns:
True if validation succeeds.
Raises:

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:
{}