Class SimpleNamespaceContext

    • Field Detail

      • parent

        protected NamespaceContext parent
        The parent context, which may be null
      • namespaces

        protected Map namespaces
        map containing bound namespaces, keyed by their prefix. A LinkedHashMap is used to ensure that getPrefix(String) always returns the same prefix, unless that prefix is removed.
    • Constructor Detail

      • SimpleNamespaceContext

        public SimpleNamespaceContext()
        Constructs a SimpleNamespaceContext with no parent context or namespace declarations.
      • SimpleNamespaceContext

        public SimpleNamespaceContext​(Map namespaces)
        Constructs a SimpleNamespaceContext with no parent context that contains the specified prefixes.
        Parameters:
        namespaces - A Map of namespace URIs, keyed by their prefixes.
      • SimpleNamespaceContext

        public SimpleNamespaceContext​(NamespaceContext parent)
        Constructs an empty SimpleNamespaceContext with the given parent. The parent context will be forwarded any requests for namespaces not declared in this context.
        Parameters:
        parent - The parent context.
      • SimpleNamespaceContext

        public SimpleNamespaceContext​(NamespaceContext parent,
                                      Map namespaces)
        Constructs an empty SimpleNamespaceContext with the given parent. The parent context will be forwarded any requests for namespaces not declared in this context.
        Parameters:
        parent - The parent context.
        namespaces - A Map of namespace URIs, keyed by their prefixes.
    • Method Detail

      • setParent

        public void setParent​(NamespaceContext parent)
        Sets the parent context used to inherit namespace bindings.
        Parameters:
        parent - The new parent context.
      • isRootContext

        public boolean isRootContext()
        Determines if this is a root context.
        Returns:
        true if this is a root context, false otherwise.
      • isPrefixDeclared

        public boolean isPrefixDeclared​(String prefix)
        Determines if the specified prefix is declared within this context, irrespective of any ancestor contexts.
        Specified by:
        isPrefixDeclared in interface ExtendedNamespaceContext
        Parameters:
        prefix - The prefix to check.
        Returns:
        true if the prefix is declared in this context, false otherwise.
      • getDeclaredPrefixCount

        public int getDeclaredPrefixCount()
        Returns the number of namespace prefixes declared in this context.
        Returns:
        The number of namespace prefixes declared in this context.
      • setDefaultNamespace

        public String setDefaultNamespace​(String nsURI)
        Sets the default namespace in this context.
        Parameters:
        nsURI - The default namespace URI.
        Returns:
        The previously declared namespace uri, or null if the default prefix wasn't previously declared in this context.
      • setPrefix

        public String setPrefix​(String prefix,
                                String nsURI)
        Declares a namespace binding in this context.
        Parameters:
        prefix - The namespace prefix.
        nsURI - The namespace URI.
        Returns:
        The previously declared namespace uri, or null if the prefix wasn't previously declared in this context.