org.jaxen

Class SimpleNamespaceContext

public class SimpleNamespaceContext extends Object implements NamespaceContext, Serializable

Provides mappings from namespace prefix to namespace URI to the XPath engine.
Field Summary
Mapnamespaces
static longserialVersionUID
Constructor Summary
SimpleNamespaceContext()
Creates a new empty namespace context.
SimpleNamespaceContext(Map namespaces)
Creates a new namespace context pre-populated with the specified bindings.
Method Summary
voidaddElementNamespaces(Navigator nav, Object element)
Adds all the namespace declarations that are in scope on the given element.
voidaddNamespace(String prefix, String URI)
Binds a prefix to a URI in this context.
StringtranslateNamespacePrefixToUri(String prefix)

Field Detail

namespaces

private Map namespaces

serialVersionUID

private static final long serialVersionUID

Constructor Detail

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.

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 null ClassCastException if any keys or values in the map are not strings

Method Detail

addElementNamespaces

public void addElementNamespaces(Navigator nav, Object element)
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">.

Parameters: nav the navigator for use in conjunction with element element the element to copy the namespaces from

Throws: UnsupportedAxisException if the navigator does not support the namespace axis

addNamespace

public void addNamespace(String prefix, String URI)
Binds a prefix to a URI in this context.

Parameters: prefix the namespace prefix URI the namespace URI

translateNamespacePrefixToUri

public String translateNamespacePrefixToUri(String prefix)