Class NamespaceContextImpl

  • All Implemented Interfaces:
    javax.xml.namespace.NamespaceContext

    public class NamespaceContextImpl
    extends java.lang.Object
    implements javax.xml.namespace.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 Summary

      Constructors 
      Constructor Description
      NamespaceContextImpl​(org.w3c.dom.Node node)
      Creates a new NamespaceContext using mappings from an existing node in some document.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNamespaceMapping​(java.lang.String prefix, java.lang.String namespaceURI)
      Add a namespace mapping this namespace context.
      java.lang.String getNamespaceURI​(java.lang.String prefix)  
      java.lang.String getPrefix​(java.lang.String namespaceURI)  
      java.util.Iterator<java.lang.String> getPrefixes​(java.lang.String namespaceURI)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NamespaceContextImpl

        public NamespaceContextImpl​(org.w3c.dom.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

      • getNamespaceURI

        public java.lang.String getNamespaceURI​(java.lang.String prefix)
        Specified by:
        getNamespaceURI in interface javax.xml.namespace.NamespaceContext
      • getPrefix

        public java.lang.String getPrefix​(java.lang.String namespaceURI)
        Specified by:
        getPrefix in interface javax.xml.namespace.NamespaceContext
      • getPrefixes

        public java.util.Iterator<java.lang.String> getPrefixes​(java.lang.String namespaceURI)
        Specified by:
        getPrefixes in interface javax.xml.namespace.NamespaceContext
      • addNamespaceMapping

        public void addNamespaceMapping​(java.lang.String prefix,
                                        java.lang.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.