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

# type 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
resetValue(self) Return the reset 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) | source code

Class Variables | [hide private]
| __xsdLocation = `None`
| __name = `None`
| __id = `None`
| __key = `None`
| __elementBinding = `None`
| __isPlural = `False`

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. To Do: This should recursively support filling in default content, as when the plural list requires a non-zero minimum number of entries.

### resetValue(self) | source code
Return the reset value for this element. For plural values, this is an empty collection. For non-plural values, it is `None`, corresponding to absence of an assigned element.

### value(self, ctd_instance) | source code
Return the value for this use within the given instance. Note that this is the resetValue(), not the defaultValue(), if the element has not yet been assigned a value.

### append(self, ctd_instance, value) | source code
Add the given value as another instance of this element within the binding instance. Raises: `pyxb.StructuralBadDocumentError` - invoked on an element use that is not plural

### 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: `pyxb.AbstractElementError` - the binding to be used is abstract

### __str__(self) (Informal representation operator) | source code
Overrides: object.__str__ (inherited documentation)