nu.xom

Class XPathContext


public final class XPathContext
extends java.lang.Object

Provides namespace prefix bindings for use in an XPath expression.
Version:
1.1b1
Author:
Elliotte Rusty Harold

Constructor Summary

XPathContext()
Creates a new XPath context that binds the xml prefix to the URI http://www.w3.org/XML/1998/namespace.
XPathContext(String prefix, String uri)
Creates a new XPath context that binds the specified prefix to the specified URI.

Method Summary

void
addNamespace(String prefix, String uri)
Binds the specified prefix to the specified namespace URI.
static XPathContext
makeNamespaceContext(Element element)
Creates a new XPath context that contains all the namespace bindings in scope on the element.

Constructor Details

XPathContext

public XPathContext()
Creates a new XPath context that binds the xml prefix to the URI http://www.w3.org/XML/1998/namespace.

XPathContext

public XPathContext(String prefix,
                    String uri)
Creates a new XPath context that binds the specified prefix to the specified URI. The xml prefix is also bound to the URI http://www.w3.org/XML/1998/namespace.
Parameters:
prefix - the prefix to bind
uri - the namespace URI the prefix is bound to

Method Details

addNamespace

public void addNamespace(String prefix,
                         String uri)
Binds the specified prefix to the specified namespace URI. If the prefix is already bound in this context, the new URI replaces the old URI. Binding a prefix to null removes the declaration. The binding of the xml prefix may not be changed.
Parameters:
prefix - the prefix to bind
uri - the namespace URI the prefix is bound to

makeNamespaceContext

public static XPathContext makeNamespaceContext(Element element)
Creates a new XPath context that contains all the namespace bindings in scope on the element. Changing the prefixes in scope on the element after the context is returned does not change the context.
Parameters:
element - the element whose namespace bindings are copied
Returns:
all the namespace prefix mappings in scope on the element

Copyright 2002-2005 Elliotte Rusty Harold
elharo@metalab.unc.edu