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 within a binding.

This gets a little confusing. Within a schema, the pyxb.xmlschema.structures.ElementDeclaration type represents an element declaration. Those declarations may be global (have a name that is visible in the namespace), or local (have a name that is visible only within a complex type definition). Further, local (but not global) declarations may have a reference to a global declaration (which might be in a different namespace).

Within a PyXB binding, the element declarations from the original complex type definition that have the same QName (after deconflicting the LocalPart) are associated with an attribute in the class for the complex type. Each of these attributes is defined via a pyxb.binding.content.ElementDeclaration which provides the mechanism by which the binding holds values associated with that element.

Furthermore, in the FAC-based content model each schema element declaration is associated with an ElementUse instance to locate the point in the schema where content came from. Instances that refer to the same schema element declaration share the same underlying pyxb.binding.content.ElementDeclaration.

This element isn't any of those elements. This element is the type used for an attribute which associates the name of a element with data required to represent it, all within a particular scope (a module for global scope, the binding class for a complex type definition for local scope). From the perspective of a PyXB user they look almost like a class, in that you can call them to create instances of the underlying complex type.

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
 
xsdLocation(self)
The pyxb.utils.utility.Location where the element appears in the schema.
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)
The default value of the element.
source code
 
fixed(self)
True if the element content cannot be changed
source code
 
substitutionGroup(self)
The element instance to whose substitution group this element belongs.
source code
 
_setSubstitutionGroup(self, substitution_group) source code
 
findSubstituendDecl(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, unicode_default=None, fixed=False, substitution_group=None, documentation=None, location=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, fallback_namespace=None, **kw)
Create an instance of this element using a DOM node as the source of its content.
source code
 
_createFromDOM(self, node, expanded_name, **kw)
Create an instance from a DOM node given the name of an element.
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]
 
CreateDOMBinding(cls, node, element_binding, **kw)
Create a binding from a DOM node.
source code
 
AnyCreateFromDOM(cls, node, fallback_namespace)
Create an instance of an element from a DOM node.
source code
Class Variables [hide private]
  __name = None
hash(x)
  __typeDefinition = None
hash(x)
  __xsdLocation = None
hash(x)
  __scope = None
hash(x)
  __nillable = False
  __abstract = False
  __documentation = None
hash(x)
  __defaultValue = None
hash(x)
  __fixed = False
  __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.

defaultValue(self)

source code 

The default value of the element.

None if the element has no default value.

Note: A non-None value is always an instance of a simple type, even if the element has complex content.

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.

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, unicode_default=None, fixed=False, substitution_group=None, documentation=None, location=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 - This keyword is removed. If present, it must be None.
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:

CreateDOMBinding(cls, node, element_binding, **kw)
Class Method

source code 

Create a binding from a DOM node.

Parameters:
  • node - The DOM node
  • element_binding - An instance of element that would normally be used to determine the type of the binding. The actual 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 node, modulated by XSI._InterpretTypeAttribute.
  • _fallback_namespace - The namespace to use as the namespace for the node, if the node name is unqualified. This should be an absent namespace.
Returns:
A binding for the DOM node.
Raises:

AnyCreateFromDOM(cls, node, fallback_namespace)
Class Method

source code 

Create an instance of an element from a DOM node.

This method does minimal processing of node and delegates to CreateDOMBinding.

Parameters:
  • node - An xml.dom.Node representing a root element. If the node is a document, that document's root node will be substituted. The name of the node is extracted as the name of the element to be created, and the node and the name are passed to CreateDOMBinding.
  • fallback_namespace - The value to pass as _fallback_namespace to CreateDOMBinding
Returns:
As with CreateDOMBinding

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, fallback_namespace=None, **kw)

source code 

Create an instance of this element using a DOM node as the source of its content.

This method does minimal processing of node and delegates to _createFromDOM.

Parameters:
  • node - An xml.dom.Node representing a root element. If the node is a document, that document's root node will be substituted. The name of the node is extracted as the name of the element to be created, and the node and the name are passed to _createFromDOM
  • fallback_namespace - Used as default for _fallback_namespace in call to _createFromDOM
Returns:
As with _createFromDOM

Note: Keyword parameters are passed to CreateDOMBinding.

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

source code 

Create an instance from a DOM node given the name of an element.

This method does minimal processing of node and expanded_name and delegates to CreateDOMBinding.

Parameters:
  • node - An xml.dom.Node representing a root element. If the node is a document, that document's root node will be substituted. The value is passed to CreateDOMBinding.
  • expanded_name - The expanded name of the element to be used for content. This is passed to elementForName to obtain the binding that is passed to CreateDOMBinding, superseding any identification that might be inferred from node. If no name is available, use createFromDOM.
Returns:
As with CreateDOMBinding.

Note: Keyword parameters are passed to CreateDOMBinding.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)