public class SimpleNamespaceContext extends java.lang.Object implements NamespaceContext, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private java.util.Map |
namespaces |
private static long |
serialVersionUID |
Constructor and Description |
---|
SimpleNamespaceContext()
Creates a new empty namespace context.
|
SimpleNamespaceContext(java.util.Map namespaces)
Creates a new namespace context pre-populated with the specified bindings.
|
Modifier and Type | Method and Description |
---|---|
void |
addElementNamespaces(Navigator nav,
java.lang.Object element)
Adds all the namespace declarations that are in scope on the given
element.
|
void |
addNamespace(java.lang.String prefix,
java.lang.String URI)
Binds a prefix to a URI in this context.
|
java.lang.String |
translateNamespacePrefixToUri(java.lang.String prefix)
Translate the provided namespace prefix into
the matching bound namespace URI.
|
private static final long serialVersionUID
private java.util.Map namespaces
public SimpleNamespaceContext()
public SimpleNamespaceContext(java.util.Map namespaces)
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.java.lang.NullPointerException
- if the argument is nulljava.lang.ClassCastException
- if any keys or values in the map are not stringspublic void addElementNamespaces(Navigator nav, java.lang.Object element) throws UnsupportedAxisException
<xsl:if test="condition/xpath/expression">
.nav
- the navigator for use in conjunction with
element
element
- the element to copy the namespaces fromUnsupportedAxisException
- if the navigator does not support the
namespace axispublic void addNamespace(java.lang.String prefix, java.lang.String URI)
prefix
- the namespace prefixURI
- the namespace URIpublic java.lang.String translateNamespacePrefixToUri(java.lang.String prefix)
NamespaceContext
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