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

type _BDSNamespaceSupport

source code

object --+
         |
        _BDSNamespaceSupport

Class holding information relevant to generating the namespace aspects of a DOM instance.

Instance Methods [hide private]
pyxb.namespace.Namespace
defaultNamespace(self)
The registered default namespace.
source code
 
setDefaultNamespace(self, default_namespace)
Set the default namespace for the generated document.
source code
 
namespacePrefixMap(self)
Return a map from Namespace instances to the prefix by which they are represented in the DOM document.
source code
 
declareNamespace(self, namespace, prefix=None, add_to_map=False)
Add the given namespace as one to be used in this document.
source code
 
namespacePrefix(self, namespace, enable_default_namespace=True)
Return the prefix to be used for the given namespace.
source code
 
namespaces(self)
Return the set of Namespace instances known to this instance.
source code
 
__resetNamespacePrefixMap(self) source code
 
reset(self, prefix_map=False)
Reset this instance to the state it was when created.
source code
 
__init__(self, default_namespace=None, namespace_prefix_map=None, inherit_from=None)
Create a new namespace declaration configuration.
source code
 
_BDSNamespaceSupport__resetNamespacePrefixMap(self) source code
Class Variables [hide private]
  __namespaces = None
  __namespacePrefixCounter = None
  __defaultNamespace = None
  __namespacePrefixMap = None
  _BDSNamespaceSupport__defaultNamespace = None
  _BDSNamespaceSupport__namespacePrefixCounter = None
  _BDSNamespaceSupport__namespacePrefixMap = None
  _BDSNamespaceSupport__namespaces = None
Method Details [hide private]

setDefaultNamespace(self, default_namespace)

source code 

Set the default namespace for the generated document.

Even if invoked post construction, the default namespace will affect the entire document, as all namespace declarations are placed in the document root.

Parameters:
  • default_namespace (pyxb.namespace.Namespace or str or unicode.) - The namespace to be defined as the default namespace in the top-level element of the document. May be provided as a real namespace, or just its URI.

declareNamespace(self, namespace, prefix=None, add_to_map=False)

source code 

Add the given namespace as one to be used in this document.

Parameters:
  • namespace (pyxb.namespace.Namespace) - The namespace to be associated with the document.
  • prefix - Optional prefix to be used with this namespace. If not provided, a unique prefix is generated or a standard prefix is used, depending on the namespace.
  • add_to_map - If False (default), the prefix is not added to the namespace prefix map. If True it is added. (Often, things added to the prefix map are preserved across resets, which is often not desired for specific prefix/namespace pairs).
To Do:
  • ensure multiple namespaces do not share the same prefix
  • provide default prefix in pyxb.namespace.Namespace
  • support multiple prefixes for each namespace

namespacePrefix(self, namespace, enable_default_namespace=True)

source code 

Return the prefix to be used for the given namespace.

This will declare the namespace if it has not yet been observed.

Parameters:
  • namespace - The namespace for which a prefix is needed. If the provided namespace is None or an absent namespace, the None value will be returned as the corresponding prefix.
  • enable_default_namespace - Normally if the namespace is the default namespace None is returned to indicate this. If this keyword is False then we need a namespace prefix even if this is the default.

reset(self, prefix_map=False)

source code 

Reset this instance to the state it was when created.

This flushes the list of namespaces for the document. The defaultNamespace is not modified.

__init__(self, default_namespace=None, namespace_prefix_map=None, inherit_from=None)
(Constructor)

source code 

Create a new namespace declaration configuration.

Parameters:
  • default_namespace - Optional pyxb.namespace.Namespace instance that serves as the default namespace (applies to unqualified names).
  • namespace_prefix_map - Optional map from pyxb.namespace.Namespace instances to str values that are to be used as the corresponding namespace prefix when constructing qualified names.
  • inherit_from - Optional instance of this class from which defaults are inherited. Inheritance is overridden by values of other keywords in the initializer.
Overrides: object.__init__