Package pyxb :: Package namespace :: Module utility
[hide private]
[frames] | no frames]

Module utility

source code

Utility functions related to XML Namespaces.

Functions [hide private]
 
NamespaceInstance(namespace)
Get a namespace instance for the given namespace.
source code
Namespace or None
NamespaceForURI(uri, create_if_missing=False)
Given a URI, provide the Namespace instance corresponding to it.
source code
 
CreateAbsentNamespace()
Create an absent namespace.
source code
 
AvailableNamespaces()
Return the complete set of Namespace instances known to the system.
source code
Variables [hide private]
  _log = logging.getLogger(__name__)
  __package__ = 'pyxb.namespace'
Function Details [hide private]

NamespaceInstance(namespace)

source code 

Get a namespace instance for the given namespace.

This is used when it is unclear whether the namespace is specified by URI or by instance or by any other mechanism we might dream up in the future.

NamespaceForURI(uri, create_if_missing=False)

source code 

Given a URI, provide the Namespace instance corresponding to it.

This can only be used to lookup or create real namespaces. To create absent namespaces, use CreateAbsentNamespace.

Parameters:
  • uri (A non-empty str or unicode string) - The URI that identifies the namespace
  • create_if_missing (bool) - If True, a namespace for the given URI is created if one has not already been registered. Default is False.
Returns: Namespace or None
The Namespace corresponding to uri, if available
Raises:

CreateAbsentNamespace()

source code 

Create an absent namespace.

Use this when you need a namespace for declarations in a schema with no target namespace. Absent namespaces are not stored in the infrastructure; it is your responsibility to hold on to the reference you get from this, because you won't be able to look it up.