Package pyxb :: Package namespace :: Module resolution :: Class NamespaceContext
[hide private]
[frames] | no frames]

Class NamespaceContext

source code

object --+
         |
        NamespaceContext

Records information associated with namespaces at a DOM node.

Instance Methods [hide private]
 
__str__(self)
str(x)
source code
 
defaultNamespace(self)
The default namespace in effect at this node.
source code
 
targetNamespace(self)
The target namespace in effect at this node.
source code
 
inScopeNamespaces(self)
Map from prefix strings to Namespace instances associated with those prefixes.
source code
 
prefixForNamespace(self, namespace)
Return a prefix associated with the given namespace in this context, or None if the namespace is the default or is not in scope.
source code
 
setNodeContext(self, node) source code
 
processXMLNS(self, prefix, uri) source code
 
finalizeTargetNamespace(self, tns_uri=None, including_context=None) source code
 
__init__(self, dom_node=None, parent_context=None, including_context=None, recurse=True, default_namespace=None, target_namespace=None, in_scope_namespaces=None, expanded_name=None, finalize_target_namespace=True)
Determine the namespace context that should be associated with the given node and, optionally, its element children.
source code
 
interpretQName(self, name, namespace=None)
Convert the provided name into an ExpandedName, i.e.
source code
 
queueForResolution(self, component, depends_on=None)
Forwards to queueForResolution() in targetNamespace().
source code

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

Class Methods [hide private]
 
_AddTargetNamespaceAttribute(cls, expanded_name, attribute_name) source code
 
_TargetNamespaceAttribute(cls, expanded_name) source code
 
GetNodeContext(cls, node, **kw)
Get the NamespaceContext instance that was assigned to the node.
source code
Class Variables [hide private]
  __TargetNamespaceAttributes = {}
  __pendingReferencedNamespaces = None
hash(x)
  __defaultNamespace = None
hash(x)
  __fallbackToTargetNamespace = False
  __targetNamespace = None
hash(x)
  __inScopeNamespaces = None
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

defaultNamespace(self)

source code 

The default namespace in effect at this node. E.g., xmlns="URN:default".

targetNamespace(self)

source code 

The target namespace in effect at this node. Usually from the targetNamespace attribute. If no namespace is specified for the schema, an absent namespace was assigned upon creation and will be returned.

inScopeNamespaces(self)

source code 

Map from prefix strings to Namespace instances associated with those prefixes. The prefix None identifies the default namespace.

GetNodeContext(cls, node, **kw)
Class Method

source code 

Get the NamespaceContext instance that was assigned to the node.

If none has been assigned and keyword parameters are present, create one treating this as the root node and the keyword parameters as configuration information (e.g., default_namespace).

Raises:
  • pyxb.LogicError - no context is available and the keywords required to create one were not provided

__init__(self, dom_node=None, parent_context=None, including_context=None, recurse=True, default_namespace=None, target_namespace=None, in_scope_namespaces=None, expanded_name=None, finalize_target_namespace=True)
(Constructor)

source code 

Determine the namespace context that should be associated with the given node and, optionally, its element children.

Parameters:
  • dom_node (xml.dom.Element) - The DOM node
  • parent_context (NamespaceContext) - Optional value that specifies the context associated with dom_node's parent node. If not provided, only the xml namespace is in scope.
  • recurse (bool) - If True (default), create namespace contexts for all element children of dom_node
  • default_namespace (NamespaceContext) - Optional value to set as the default namespace. Values from parent_context would override this, as would an xmlns attribute in the dom_node.
  • target_namespace (NamespaceContext) - Optional value to set as the target namespace. Values from parent_context would override this, as would a targetNamespace attribute in the dom_node
  • in_scope_namespaces (dict mapping string to Namespace.) - Optional value to set as the initial set of in-scope namespaces. The always-present namespaces are added to this if necessary.
Overrides: object.__init__

interpretQName(self, name, namespace=None)

source code 

Convert the provided name into an ExpandedName, i.e. a tuple of Namespace and local name.

If the name includes a prefix, that prefix must map to an in-scope namespace in this context. Absence of a prefix maps to defaultNamespace(), which must be provided (or defaults to the target namespace, if that is absent).

Parameters:
  • name (str or unicode) - A QName.
  • name (str or unicode) - Optional namespace to use for unqualified names when there is no default namespace. Note that a defined default namespace, even if absent, supersedes this value.
Returns:
An ExpandedName tuple: ( Namespace, str )
Raises: