:tocdepth: 3 :py:mod:`gws.lib.xmlx.namespace` ================================ .. py:module:: gws.lib.xmlx.namespace .. autoapi-nested-parse:: XML namespace manager. Maintains a registry of XML namespaces (well-known and custom). **Source code:** :source:`gws.lib.xmlx.namespace` Module Contents --------------- .. py:function:: clarkify_name(name: str) -> str Returns an XML name in the Clark notation. :param name: A qualified XML name. :returns: The XML name in Clark notation. .. py:function:: declarations(namespaces: dict[str, gws.XmlNamespace], with_schema_locations: bool = False) -> dict Returns an xmlns declaration block as dictionary of attributes. :param namespaces: Mapping from prefixes to namespaces. :param with_schema_locations: Add the "schemaLocation" attribute. :returns: A dict of attributes. .. py:function:: extract(name: str) -> tuple[Optional[gws.XmlNamespace], str] Extract a Namespace object from a qualified name. :param name: XML name. :returns: A tuple ``(XmlNamespace, proper name)`` .. py:function:: find_by_uri(uri: str) -> Optional[gws.XmlNamespace] Locate the Namespace by an Uri. .. py:function:: find_by_xmlns(xmlns: str) -> Optional[gws.XmlNamespace] Locate the Namespace by an xmlns prefix. .. py:function:: from_args(**kwargs) -> gws.XmlNamespace Create a Namespace from keyword arguments. .. py:function:: get(uid: str) -> Optional[gws.XmlNamespace] Locate the Namespace by a uid. .. py:function:: qualify_name(name: str, ns: Optional[gws.XmlNamespace] = None, replace: bool = False) -> str Qualify an XML name. :param name: An XML name. :param ns: A namespace. :param replace: If true, replace the existing namespace. :returns: A qualified name. .. py:function:: register(ns: gws.XmlNamespace) Add a Namespace to an internal registry. .. py:function:: require(uid: str) -> gws.XmlNamespace Locate the Namespace by a uid. .. py:function:: split_name(name: str) -> tuple[str, str, str] Parse an XML name in a xmlns: or Clark notation. :param name: XML name. :returns: A tuple ``(xmlns-prefix, uri, proper name)``. .. py:function:: unqualify_default(name: str, default_namespace: gws.XmlNamespace) -> str Removes the default namespace prefix. If the name contains the default namespace, remove it, otherwise return the name as is. :param name: An XML name. :param default_namespace: A namespace. :returns: The name. .. py:function:: unqualify_name(name: str) -> str Returns an unqualified XML name. .. py:data:: XMLNS :value: 'xmlns'