Package pyxb :: Package binding :: Module content :: Class ElementDeclaration
[hide private]
[frames] | no frames]

Class ElementDeclaration

source code

object --+
         |
        ElementDeclaration

Aggregate the information relevant to an element of a complex type.

This includes the original tag name, the spelling of the corresponding object in Python, an indicator of whether multiple instances might be associated with the field, and other relevant information.

Instance Methods [hide private]
 
xsdLocation(self)
The location in the schema where the element was declared.
source code
pyxb.namespace.ExpandedName
name(self)
The expanded name of the element.
source code
 
id(self)
The string name of the binding class field used to hold the element values.
source code
 
elementBinding(self)
The basis.element instance identifying the information associated with the element declaration.
source code
 
_setElementBinding(self, element_binding) source code
 
isPlural(self)
True iff the content model indicates that more than one element can legitimately belong to this use.
source code
 
__init__(self, name, id, key, is_plural, location, element_binding=None)
Create an ElementDeclaration instance.
source code
 
defaultValue(self)
Return the default value for this element.
source code
 
value(self, ctd_instance)
Return the value for this use within the given instance.
source code
 
reset(self, ctd_instance)
Set the value for this use in the given element to its default.
source code
 
set(self, ctd_instance, value)
Set the value of this element in the given instance.
source code
 
setOrAppend(self, ctd_instance, value)
Invoke either set or append, depending on whether the element use is plural.
source code
 
append(self, ctd_instance, value)
Add the given value as another instance of this element within the binding instance.
source code
 
toDOM(self, dom_support, parent, value)
Convert the given value to DOM as an instance of this element.
source code
 
_description(self, name_only=False, user_documentation=True) source code
 
_matches(self, value, element_decl) source code
 
__str__(self)
str(x)
source code

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

Class Variables [hide private]
  __xsdLocation = None
hash(x)
  __name = None
hash(x)
  __id = None
hash(x)
  __key = None
hash(x)
  __elementBinding = None
hash(x)
  __isPlural = False
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

xsdLocation(self)

source code 

The location in the schema where the element was declared.

Note that this is not necessarily the same location as its use.

id(self)

source code 

The string name of the binding class field used to hold the element values.

This is the user-visible name, and excepting disambiguation will be equal to the local name of the element.

isPlural(self)

source code 

True iff the content model indicates that more than one element can legitimately belong to this use.

This includes elements in particles with maxOccurs greater than one, and when multiple elements with the same NCName are declared in the same type.

__init__(self, name, id, key, is_plural, location, element_binding=None)
(Constructor)

source code 

Create an ElementDeclaration instance.

Parameters:
  • name (pyxb.namespace.ExpandedName) - The name by which the element is referenced in the XML
  • id (str) - The Python name for the element within the containing pyxb.basis.binding.complexTypeDefinition. This is a public identifier, albeit modified to be unique, and is usually used as the name of the element's inspector method or property.
  • key (str) - The string used to store the element value in the dictionary of the containing pyxb.basis.binding.complexTypeDefinition. This is mangled so that it is unique among and is treated as a Python private member.
  • is_plural (bool) - If True, documents for the corresponding type may have multiple instances of this element. As a consequence, the value of the element will be a list. If False, the value will be None if the element is absent, and a reference to an instance of the type identified by pyxb.binding.basis.element.typeDefinition if present.
  • element_binding - Reference to the class that serves as the binding for the element.
Overrides: object.__init__

defaultValue(self)

source code 

Return the default value for this element.

For plural values, this is an empty collection. For non-plural values, it is None unless the element has a default value, in which case it is that value.

append(self, ctd_instance, value)

source code 

Add the given value as another instance of this element within the binding instance.

Raises:

toDOM(self, dom_support, parent, value)

source code 

Convert the given value to DOM as an instance of this element.

Parameters:
  • dom_support (pyxb.utils.domutils.BindingDOMSupport) - Helper for managing DOM properties
  • parent (xml.dom.Element) - The DOM node within which this element should be generated.
  • value - The content for this element. May be text (if the element allows mixed content), or an instance of basis._TypeBinding_mixin.
Raises:

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)