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

Class element

source code

                            object --+    
                                     |    
utils.utility._DeconflictSymbols_mixin --+
                                         |
                        object --+       |
                                 |       |
                           cscRoot --+   |
                                     |   |
                  _DynamicCreate_mixin --+
                                         |
                                        element

Class that represents a schema element.

Global and local elements are represented by instances of this class.

Instance Methods [hide private]
 
name(self)
The expanded name of the element within its scope.
source code
 
typeDefinition(self)
The _TypeBinding_mixin subclass for values of this element.
source code
 
scope(self)
The scope of the element.
source code
 
nillable(self)
Indicate whether values matching this element can have nil set.
source code
 
abstract(self)
Indicate whether this element is abstract (must use substitution group members for matches).
source code
 
documentation(self)
Contents of any documentation annotation in the definition.
source code
 
defaultValue(self) source code
 
substitutionGroup(self)
The element instance to whose substitution group this element belongs.
source code
 
_setSubstitutionGroup(self, substitution_group) source code
 
findSubstituendUse(self, ctd_class) source code
 
_real_substitutesFor(self, other)
Determine whether an instance of this element can substitute for the other element.
source code
 
substitutesFor(self, other)
Stub replaced by _real_substitutesFor when element supports substitution groups.
source code
 
memberElement(self, name)
Return a reference to the element instance used for the given name within this element.
source code
 
__init__(self, name, type_definition, scope=None, nillable=False, abstract=False, default_value=None, substitution_group=None, documentation=None)
Create a new element binding.
source code
 
__call__(self, *args, **kw)
Invoke the Factory method on the type associated with this element.
source code
 
compatibleValue(self, value, **kw)
Return a variant of the value that is compatible with this element.
source code
 
elementForName(self, name)
Return the element that should be used if this element binding is permitted and an element with the given name is encountered.
source code
 
createFromDOM(self, node, expanded_name=None, fallback_namespace=None, **kw)
Create a binding instance from the given DOM node.
source code
 
_createFromDOM(self, node, expanded_name, **kw)
Create a binding instance from the given DOM node, using the provided name to identify the correct binding.
source code
 
__str__(self)
str(x)
source code
 
_description(self, name_only=False, user_documentation=True) source code

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

Class Methods [hide private]
 
AnyCreateFromDOM(cls, node, _fallback_namespace) source code
Class Variables [hide private]
  __name = None
hash(x)
  __typeDefinition = None
hash(x)
  __scope = None
hash(x)
  __nillable = False
  __abstract = False
  __documentation = None
hash(x)
  __defaultValue = None
hash(x)
  __substitutionGroup = None
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

scope(self)

source code 

The scope of the element. This is either None, representing a top-level element, or an instance of complexTypeDefinition for local elements.

substitutionGroup(self)

source code 

The element instance to whose substitution group this element belongs. None if this element is not part of a substitution group.

_real_substitutesFor(self, other)

source code 

Determine whether an instance of this element can substitute for the other element.

See Substitution Group OK<http://www.w3.org/TR/xmlschema-1/#cos-equiv-derived-ok-rec>).

To Do: Do something about blocking constraints. This ignores them, as does everything leading to this point.

memberElement(self, name)

source code 

Return a reference to the element instance used for the given name within this element.

The type for this element must be a complex type definition.

__init__(self, name, type_definition, scope=None, nillable=False, abstract=False, default_value=None, substitution_group=None, documentation=None)
(Constructor)

source code 

Create a new element binding.

Overrides: object.__init__

__call__(self, *args, **kw)
(Call operator)

source code 

Invoke the Factory method on the type associated with this element.

Parameters:
  • _dom_node - If set, specifies a DOM node that should be used for initialization. In that case, the createFromDOM method is invoked instead of the type definition Factory method.
Raises:

Note: Other keywords are passed to _TypeBinding_mixin.Factory.

compatibleValue(self, value, **kw)

source code 

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

This mostly defers to _TypeBinding_mixin._CompatibleValue.

Raises:
  • pyxb.BadTypeValueError - if the value is not both type-consistent and value-consistent with the element's type.

elementForName(self, name)

source code 

Return the element that should be used if this element binding is permitted and an element with the given name is encountered.

Normally, the incoming name matches the name of this binding, and self is returned. If the incoming name is different, it is expected to be the name of a global element which is within this element's substitution group. In that case, the binding corresponding to the named element is return.

Returns:
An instance of element, or None if no element with the given name can be found.

createFromDOM(self, node, expanded_name=None, fallback_namespace=None, **kw)

source code 

Create a binding instance from the given DOM node.

Parameters:
  • expanded_name - Optional name for the DOM node. If not present, is inferred from node.
  • fallback_namespace - Optional namespace to use when resolving unqualified names.

_createFromDOM(self, node, expanded_name, **kw)

source code 

Create a binding instance from the given DOM node, using the provided name to identify the correct binding.

The context and information associated with this element is used to identify the actual element binding to use. By default, self is used. If this element represents a term in a content model, the name and namespace of the incoming node may identify a different element. If that element is a member of this element's substitution group, the binding associated with the node's name will be used instead.

The type of object returned is determined by the type definition associated with the element binding and the value of any xsi:type attribute found in the node, modulated by the configuration of XSI.ProcessTypeAttribute.

Keyword parameters are passed to the factory method of the type associated with the selected element binding. See _TypeBinding_mixin and any specializations of it.

Parameters:
  • expanded_name - The expanded name of the node. If the value is None, defaults to the name of this element. (In the case of substitution groups, the default is wrong, but correct inference depends on context not available here.)
  • _fallback_namespace - Optional namespace to use when resolving unqualified type names.
  • node (xml.dom.Node) - The DOM node specifying the element content. If this is a (top-level) Document node, its element node is used.
Returns:
An instance of _TypeBinding_mixin
Raises:

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)