org.jaxen
Class SimpleNamespaceContext
java.lang.Object
org.jaxen.SimpleNamespaceContext
- NamespaceContext, Serializable
public class SimpleNamespaceContext
extends java.lang.Object
Provides mappings from namespace prefix to namespace URI to the XPath
engine.
namespaces
private Map namespaces
serialVersionUID
private static final long serialVersionUID
SimpleNamespaceContext
public SimpleNamespaceContext()
Creates a new empty namespace context.
SimpleNamespaceContext
public SimpleNamespaceContext(Map namespaces)
Creates a new namespace context pre-populated with the specified bindings.
namespaces
- the initial namespace bindings in scope. The keys in this
must be strings containing the prefixes and the values are strings
containing the namespace URIs.
addElementNamespaces
public void addElementNamespaces(Navigator nav,
Object element)
throws UnsupportedAxisException
Adds all the namespace declarations that are in scope on the given
element. In the case of an XSLT stylesheet, this would be the element
that has the XPath expression in one of its attributes; e.g.
<xsl:if test="condition/xpath/expression">
.
nav
- the navigator for use in conjunction with
element
element
- the element to copy the namespaces from
addNamespace
public void addNamespace(String prefix,
String URI)
Binds a prefix to a URI in this context.
prefix
- the namespace prefixURI
- the namespace URI
translateNamespacePrefixToUri
public String translateNamespacePrefixToUri(String prefix)
Translate the provided namespace prefix into
the matching bound namespace URI.
In XPath, there is no such thing as a 'default namespace'.
The empty prefix
always resolves to the empty
namespace URI. This method should return null for the
empty prefix.
Similarly, the prefix "xml" always resolves to
the URI "http://www.w3.org/XML/1998/namespace".
- translateNamespacePrefixToUri in interface NamespaceContext
prefix
- the namespace prefix to resolve
- the namespace URI bound to the prefix; or null if there
is no such namespace