Package org.jaxen
Class SimpleNamespaceContext
java.lang.Object
org.jaxen.SimpleNamespaceContext
- All Implemented Interfaces:
Serializable
,NamespaceContext
Provides mappings from namespace prefix to namespace URI to the XPath
engine.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty namespace context.SimpleNamespaceContext
(Map namespaces) Creates a new namespace context pre-populated with the specified bindings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.translateNamespacePrefixToUri
(String prefix) Translate the provided namespace prefix into the matching bound namespace URI.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
namespaces
-
-
Constructor Details
-
SimpleNamespaceContext
public SimpleNamespaceContext()Creates a new empty namespace context. -
SimpleNamespaceContext
Creates a new namespace context pre-populated with the specified bindings.- Parameters:
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.- Throws:
NullPointerException
- if the argument is nullClassCastException
- if any keys or values in the map are not strings
-
-
Method Details
-
addNamespace
Binds a prefix to a URI in this context.- Parameters:
prefix
- the namespace prefixURI
- the namespace URI
-
translateNamespacePrefixToUri
Description copied from interface:NamespaceContext
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".
- Specified by:
translateNamespacePrefixToUri
in interfaceNamespaceContext
- Parameters:
prefix
- the namespace prefix to resolve- Returns:
- the namespace URI bound to the prefix; or null if there is no such namespace