org.apache.xpath.jaxp
Class JAXPPrefixResolver

java.lang.Object
  extended by org.apache.xpath.jaxp.JAXPPrefixResolver
All Implemented Interfaces:
PrefixResolver

public class JAXPPrefixResolver
extends java.lang.Object
implements PrefixResolver

This class implements a Default PrefixResolver which can be used to perform prefix-to-namespace lookup for the XPath object. This class delegates the resolution to the passed NamespaceContext


Field Summary
private  javax.xml.namespace.NamespaceContext namespaceContext
           
static java.lang.String S_XMLNAMESPACEURI
          The URI for the XML namespace.
 
Constructor Summary
JAXPPrefixResolver(javax.xml.namespace.NamespaceContext nsContext)
           
 
Method Summary
 java.lang.String getBaseIdentifier()
          Return the base identifier.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix)
          Given a namespace, get the corrisponding prefix.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix, org.w3c.dom.Node namespaceContext)
          Given a prefix and a Context Node, get the corresponding namespace.
 boolean handlesNullPrefixes()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

namespaceContext

private javax.xml.namespace.NamespaceContext namespaceContext

S_XMLNAMESPACEURI

public static final java.lang.String S_XMLNAMESPACEURI
The URI for the XML namespace. (Duplicate of that found in org.apache.xpath.XPathContext).

See Also:
Constant Field Values
Constructor Detail

JAXPPrefixResolver

public JAXPPrefixResolver(javax.xml.namespace.NamespaceContext nsContext)
Method Detail

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix)
Description copied from interface: PrefixResolver
Given a namespace, get the corrisponding 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.

getBaseIdentifier

public java.lang.String getBaseIdentifier()
Return the base identifier.

Specified by:
getBaseIdentifier in interface PrefixResolver
Returns:
null

handlesNullPrefixes

public boolean handlesNullPrefixes()
Specified by:
handlesNullPrefixes in interface PrefixResolver
See Also:
PrefixResolver.handlesNullPrefixes()

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix,
                                              org.w3c.dom.Node namespaceContext)
Given a prefix and a Context Node, get the corresponding namespace. Warning: This will not work correctly if namespaceContext is an attribute node.

Specified by:
getNamespaceForPrefix in interface PrefixResolver
Parameters:
prefix - Prefix to resolve.
namespaceContext - Node from which to start searching for a xmlns attribute that binds a prefix to a namespace.
Returns:
Namespace that prefix resolves to, or null if prefix is not bound.