public class SimpleNamespaceContext extends Object implements NamespaceContext, Serializable
Constructor and Description |
---|
SimpleNamespaceContext()
Creates a new empty namespace context.
|
SimpleNamespaceContext(Map namespaces)
Creates a new namespace context pre-populated with the specified bindings.
|
Modifier and Type | Method and Description |
---|---|
void |
addElementNamespaces(Navigator nav,
Object element)
Adds all the namespace declarations that are in scope on the given
element.
|
void |
addNamespace(String prefix,
String URI)
Binds a prefix to a URI in this context.
|
String |
translateNamespacePrefixToUri(String prefix)
Translate the provided namespace prefix into
the matching bound namespace URI.
|
public SimpleNamespaceContext()
public SimpleNamespaceContext(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.NullPointerException
- if the argument is nullClassCastException
- if any keys or values in the map are not stringspublic void addElementNamespaces(Navigator nav, 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(String prefix, String URI)
prefix
- the namespace prefixURI
- the namespace URIpublic String translateNamespacePrefixToUri(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 resolveCopyright 2001–2022 The Jaxen Project. All rights reserved.