Package pyxb :: Package utils :: Module domutils :: Class BindingDOMSupport |
[hide private]
[frames] | no frames]

# type BindingDOMSupport

source code

    object --+
             |
            BindingDOMSupport

This holds DOM-related information used when generating a DOM tree from a binding instance.

Instance Methods | [hide private]
implementation(self) The DOMImplementation object to be used. | source code
document(self) Return the document generated using this instance. | source code
requireXSIType(self) Indicates whether {xsi:type<http://www.w3.org/TR/xmlschema-1/#xsi_type>} should be added to all elements. | source code
reset(self, **kw) Reset this instance to the state it was when created. | source code
__init__(self, implementation=None, default_namespace=None, require_xsi_type=False, namespace_prefix_map=None) Create a new instance used for building a single document. | source code
defaultNamespace(self) The default namespace for this instance | source code
setDefaultNamespace(self, default_namespace) | source code
declareNamespace(self, namespace, prefix=None) Declare a namespace within this instance only. | source code
namespacePrefix(self, namespace, enable_default_namespace=True) Obtain the prefix for the given namespace using this instance's configuration. | source code
namespacePrefixMap(self) Get the map from namespaces to prefixes for this instance | source code
addAttribute(self, element, expanded_name, value) Add an attribute to the given element. | source code
`xml.dom.Document` |
finalize(self) Do the final cleanup after generating the tree. | source code
`xml.dom.Element` |
createChildElement(self, expanded_name, parent=None) Create a new element node in the tree. | source code
`( str, str )` |
_makeURINodeNamePair(self, node) Convert namespace information from a DOM node to text for new DOM node. | source code
_deepClone(self, node, docnode) | source code
cloneIntoImplementation(self, node) Create a deep copy of the node in the target implementation. | source code
`xml.dom.Node` |
appendChild(self, child, parent) Add the child to the parent. | source code
appendTextChild(self, text, parent) Add the text to the parent as a text node. | source code

Class Methods | [hide private]
Reset(cls, **kw) Reset the global defaults for default/prefix/namespace informmation. | source code
DefaultNamespace(cls) The global default namespace (used on instance creation if not overridden) | source code
SetDefaultNamespace(cls, default_namespace) | source code
DeclareNamespace(cls, namespace, prefix=None) Declare a namespace that will be added to each created instance. | source code
NamespacePrefixMap(cls) Get the map of default namespace-to-prefix mappings | source code

Class Variables | [hide private]
| __implementation = `None`
| __document = `None`
| __requireXSIType = `None`
| __namespaceSupport = `None`
| __NamespaceSupport = `_BDSNamespaceSupport()`

Method Details | [hide private]

### implementation(self) | source code
The DOMImplementation object to be used. Defaults to pyxb.utils.domutils.GetDOMImplementation(), but can be overridden in the constructor call using the `implementation` keyword.

### requireXSIType(self) | source code
Indicates whether {xsi:type<http://www.w3.org/TR/xmlschema-1/#xsi_type>} should be added to all elements. Certain WSDL styles and encodings seem to require explicit notation of the type of each element, even if it was specified in the schema. This value can only be set in the constructor.

### reset(self, **kw) | source code
Reset this instance to the state it was when created. This creates a new root document with no content, and flushes the list of namespaces for the document. The defaultNamespace and requireXSIType are not modified.

### __init__(self, implementation=None, default_namespace=None, require_xsi_type=False, namespace_prefix_map=None) (Constructor) | source code
Create a new instance used for building a single document. Parameters: `implementation` - The `xml.dom` implementation to use. Defaults to the one selected by GetDOMImplementation. `default_namespace` (pyxb.namespace.Namespace) - The namespace to configure as the default for the document. If not provided, there is no default namespace. `require_xsi_type` (`bool`) - If `True`, an xsi:type attribute should be placed in every element. `namespace_prefix_map` (`map` from pyxb.namespace.Namespace to `str`) - A map from pyxb.namespace.Namespace instances to the preferred prefix to use for the namespace in xmlns declarations. The default one assigns 'xsi' for the XMLSchema instance namespace. Raises: `pyxb.LogicError` - the same prefix is associated with multiple namespaces in the `namespace_prefix_map`. Overrides: object.__init__

### addAttribute(self, element, expanded_name, value) | source code
Add an attribute to the given element. Parameters: `element` (`xml.dom.Element`) - The element to which the attribute should be added `expanded_name` (pyxb.namespace.Namespace or `str` or `unicode`) - The name of the attribute. This may be a local name if the attribute is not in a namespace. `value` (`str` or `unicode`) - The value of the attribute

### finalize(self) | source code
Do the final cleanup after generating the tree. This makes sure that the document element includes XML Namespace declarations for all namespaces referenced in the tree. Returns: `xml.dom.Document` The document that has been created.

### createChildElement(self, expanded_name, parent=None) | source code
Create a new element node in the tree. Parameters: `expanded_name` (pyxb.namespace.ExpandedName or `str` or `unicode`) - The name of the element. A plain string indicates a name in no namespace. `parent` - The node in the tree that will serve as the child's parent. If `None`, the document element is used. (If there is no document element, then this call creates it as a side-effect.) Returns: `xml.dom.Element` A newly created DOM element

### _makeURINodeNamePair(self, node) | source code
Convert namespace information from a DOM node to text for new DOM node. The namespaceURI and nodeName are extracted and parsed. The namespace (if any) is registered within the document, along with any prefix from the node name. A pair is returned where the first element is the namespace URI or `None`, and the second is a QName to be used for the expanded name within this document. Parameters: `node` - An xml.dom.Node instance, presumably from a wildcard match. Returns: `( str, str )`

### cloneIntoImplementation(self, node) | source code
Create a deep copy of the node in the target implementation. Used when converting a DOM instance from one implementation (e.g., pyxb.utils.saxdom) into another (e.g., xml.dom.minidom).

### appendChild(self, child, parent) | source code
Add the child to the parent. Parameters: `child` (`xml.dom.Node`) - The value to be appended `parent` (`xml.dom.Node`) - The new parent of the child Returns: `xml.dom.Node` Note: If the child and the parent use different DOM implementations, this operation will clone the child into a new instance, and give that to the parent.