Class PrefixResolverDefault

  • All Implemented Interfaces:
    PrefixResolver

    public class PrefixResolverDefault
    extends java.lang.Object
    implements PrefixResolver
    This class implements a generic PrefixResolver that can be used to perform prefix-to-namespace lookup for the XPath object.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) org.w3c.dom.Node m_context
      The context to resolve the prefix from, if the context is not given.
    • Constructor Summary

      Constructors 
      Constructor Description
      PrefixResolverDefault​(org.w3c.dom.Node xpathExpressionContext)
      Construct a PrefixResolverDefault object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getNamespaceForPrefix​(java.lang.String prefix)
      Given a namespace, get the corresponding prefix.
      java.lang.String getNamespaceForPrefix​(java.lang.String prefix, org.w3c.dom.Node namespaceContext)
      Given a namespace, get the corresponding prefix, based on the context node.
      boolean handlesNullPrefixes()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_context

        final org.w3c.dom.Node m_context
        The context to resolve the prefix from, if the context is not given.
    • Constructor Detail

      • PrefixResolverDefault

        public PrefixResolverDefault​(org.w3c.dom.Node xpathExpressionContext)
        Construct a PrefixResolverDefault object.
        Parameters:
        xpathExpressionContext - The context from which XPath expression prefixes will be resolved. Warning: This will not work correctly if xpathExpressionContext is an attribute node.
    • Method Detail

      • getNamespaceForPrefix

        public java.lang.String getNamespaceForPrefix​(java.lang.String prefix)
        Given a namespace, get the corresponding prefix. This assumes that the PrefixResolver holds its own namespace context, or is a namespace context itself.
        Specified by:
        getNamespaceForPrefix in interface PrefixResolver
        Parameters:
        prefix - The prefix to look up, which may be an empty string ("") for the default Namespace.
        Returns:
        The associated Namespace URI, or null if the prefix is undeclared in this context.
      • getNamespaceForPrefix

        public java.lang.String getNamespaceForPrefix​(java.lang.String prefix,
                                                      org.w3c.dom.Node namespaceContext)
        Given a namespace, get the corresponding prefix, based on the context node.
        Specified by:
        getNamespaceForPrefix in interface PrefixResolver
        Parameters:
        prefix - The prefix to look up, which may be an empty string ("") for the default Namespace.
        namespaceContext - The node context from which to look up the URI.
        Returns:
        The associated Namespace URI as a string, or null if the prefix is undeclared in this context.