Class NamespaceContextImpl

  • All Implemented Interfaces:
    NamespaceContext

    public class NamespaceContextImpl
    extends Object
    implements NamespaceContext
    Implements the interface javax.xml.namespace.NamespaceContext using the namespace prefix mapping in scope from an existing Node.

    Normally, the namespace prefixes mappings in an XPath expression are unrelated to any namespace mappings in the XML document, but this implementation uses the existing in-scope namespace mappings from some node in the document to define a set of mappings.

    Additional mappings can be added explicitly.

    • Constructor Detail

      • NamespaceContextImpl

        public NamespaceContextImpl​(Node node)
        Creates a new NamespaceContext using mappings from an existing node in some document.
        Parameters:
        node - a node to use the in-scope namespace mappings from; if null then no namespace mappings are defined.
    • Method Detail

      • addNamespaceMapping

        public void addNamespaceMapping​(String prefix,
                                        String namespaceURI)
        Add a namespace mapping this namespace context.

        Additional namespace mappings can be added to this NamespaceContext -- mappings which aren't expressed anywhere in the document's elements.

        Mappings provided through this method will be used only as a last resort. If an element's mapping redefines either the prefix or namespace URI given in this call, the element's definition will take precedence for it and its descendants.

        Parameters:
        prefix - Namespace prefix, empty string for default mapping namespace.
        namespaceURI - Namespace URI associated with the prefix.