: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(default_ns: Optional[gws.XmlNamespace] = None, for_element: gws.XmlElement = None, extra_ns: Optional[list[gws.XmlNamespace]] = None, with_schema_locations: bool = False) -> dict Returns an xmlns declaration block as dictionary of attributes. :param default_ns: Default namespace. :param for_element: If given, collect namespaces from this element and its descendants. :param extra_ns: Extra namespaces to create declarations for. :param with_schema_locations: Add the "schema location" attribute. :returns: A dict of attributes. .. py:function:: find_by_uri(uri: str) -> Optional[gws.XmlNamespace] 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``. :param uri: An Uri like ``http://www.opengis.net/gml``. :returns: A Namespace. .. py:function:: find_by_xmlns(xmlns: str) -> Optional[gws.XmlNamespace] Locate the Namespace by a name. :param xmlns: A name like ``gml``. :returns: A Namespace. .. py:function:: get(s: str) -> Optional[gws.XmlNamespace] Locate the Namespace by a name. :param s: A uid like ``gml3``, name like ``gml`` or an Uri like ``http://www.opengis.net/gml``. :returns: A Namespace. .. py:function:: parse_name(name: str) -> tuple[Optional[gws.XmlNamespace], str] Parses an XML name. :param name: XML name. :returns: A tuple ``(XmlNamespace, proper name)`` .. py:function:: qualify_name(name: str, ns: gws.XmlNamespace, replace: bool = False) -> str Qualifies an XML name. If the name contains a namespace, return as is, otherwise, prepend the namespace. :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) Register a Namespace. :param ns: Namespace .. py:function:: split_name(name: str) -> tuple[str, str, str] Parses an XML name. :param name: XML name. :returns: A tuple ``(xmlns, uri, proper name)``. .. py:function:: unqualify_default(name: str, default_ns: 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_ns: A namespace. :returns: The name. .. py:function:: unqualify_name(name: str) -> str Returns an unqualified XML name.