module documentation

XML namespace manager.

Manage XML namespaces.

Function clarkify_name Returns an XML name in the Clark notation.
Function declarations Returns an xmlns declaration block as dictionary of attributes.
Function find_by_uri Locate the Namespace by an Uri.
Function find_by_xmlns Locate the Namespace by a name.
Function get Undocumented
Function parse_name Undocumented
Function qualify_name Qualifies an XML name.
Function register Register a Namespace.
Function split_name Parses an XML name.
Function unqualify_default Removes the default namespace prefx.
Function unqualify_name Returns an unqualified XML name.
Class _Index Undocumented
Function _collect_namespaces Undocumented
Function _load_known Undocumented
Function _parse_versioned_uri Undocumented
Constant _INDEX Undocumented
Constant _KNOWN_NAMESPACES Undocumented
Constant _XMLNS Undocumented
Constant _XSI Undocumented
Constant _XSI_URL Undocumented
def clarkify_name(name: str) -> str: (source)

Returns an XML name in the Clark notation.

def declarations(default_ns: t.Optional[gws.XmlNamespace] = None, for_element: gws.IXmlElement = None, extra_ns: t.Optional[list[gws.XmlNamespace]] = None, with_schema_locations: bool = False) -> dict: (source)

Returns an xmlns declaration block as dictionary of attributes.

Parameters
default_ns:t.Optional[gws.XmlNamespace]Default namespace.
for_element:gws.IXmlElementIf given, collect namespaces from this element and its descendants.
extra_ns:t.Optional[list[gws.XmlNamespace]]Extra namespaces to create declarations for.
with_schema_locations:boolAdd the "schema location" attribute.
Returns
dictA dict of attributes.
def find_by_uri(uri: str) -> t.Optional[gws.XmlNamespace]: (source)

Locate the Namespace by an Uri.

If the Uri ends with a version number, and there is no namespace for this specific Uri, try to locate a non-versioned Uri. That is, http://www.opengis.net/gml/9999 will look up for http://www.opengis.net/gml.

Parameters
uri:strAn Uri like http://www.opengis.net/gml.
Returns
t.Optional[gws.XmlNamespace]A Namespace.
def find_by_xmlns(xmlns: str) -> t.Optional[gws.XmlNamespace]: (source)

Locate the Namespace by a name.

Parameters
xmlns:strA name like gml.
Returns
t.Optional[gws.XmlNamespace]A Namespace.
def get(s: str) -> t.Optional[gws.XmlNamespace]: (source)

Undocumented

def parse_name(name: str) -> tuple[t.Optional[gws.XmlNamespace], str]: (source)

Undocumented

def qualify_name(name: str, ns: gws.XmlNamespace, replace=False) -> str: (source)

Qualifies an XML name.

If the name contains a namespace, return as is, otherwise, prepend the namespace.

Parameters
name:strAn XML name.
ns:gws.XmlNamespaceA namespace.
replaceIf true, replace the existing namespace.
Returns
strA quailified name.

Register a Namespace.

Parameters
ns:gws.XmlNamespaceNamespace
def split_name(name: str) -> tuple[str, str, str]: (source)

Parses an XML name.

Parameters
name:strXML name.
Returns
tuple[str, str, str]A tuple (xmlns, uri, proper name).
def unqualify_default(name: str, default_ns: gws.XmlNamespace) -> str: (source)

Removes the default namespace prefx.

If the name contains the default namespace, remove it, otherwise return the name as is.

Parameters
name:strAn XML name.
default_ns:gws.XmlNamespaceA namespace.
Returns
strThe name.
def unqualify_name(name: str) -> str: (source)

Returns an unqualified XML name.

def _collect_namespaces(el: gws.IXmlElement, uri_map): (source)

Undocumented

def _load_known(): (source)

Undocumented

def _parse_versioned_uri(uri: str) -> tuple[str, str]: (source)

Undocumented

Undocumented

Value
_Index()
_KNOWN_NAMESPACES: str = (source)

Undocumented

Value
'''
xml              |                  |       | www.w3.org/XML/1998/namespace     
            |
html             |                  |       | www.w3.org/1999/xhtml             
            |
wsdl             |                  |       | schemas.xmlsoap.org/wsdl          
            |
...
_XMLNS: str = (source)

Undocumented

Value
'xmlns'
_XSI: str = (source)

Undocumented

Value
'xsi'
_XSI_URL: str = (source)

Undocumented

Value
'http://www.w3.org/2001/XMLSchema-instance'