public class XPathContext
extends java.lang.Object
Impelementations may wish to extend this class and provide additional facilities for locating the document order of a node, or providing a function library.
| Constructor and Description |
|---|
XPathContext(VariableSet variables,
NodeSet nodeSet,
int position)
Constructs a new XPath context.
|
XPathContext(XPathNode node)
Constructs a new XPath context using the given node
as the context node.
|
XPathContext(XPathNode node,
VariableSet variables)
Constructs a new XPath context using the given node as
as the context node.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNamespaceBinding(java.lang.String prefix,
java.lang.String namespace)
Creates a binding within this XPathContext between a given prefix
and a namespace URI.
|
int[] |
getDocumentOrder(XPathNode node)
Returns the document order of the given node.
|
XPathNode |
getElementById(XPathNode root,
java.lang.String id)
Returns the element associated with the given identifier.
|
XPathFunction |
getFunction(java.lang.String uri,
java.lang.String name)
Returns the XPath function by the given name, or null if no
such function is defined.
|
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Returns the namespace associated with the given prefix as
defined in this context.
|
XPathNode |
getNode()
Returns the context node of this XPathContext
|
NodeSet |
getNodeSet()
Returns the current context node-set.
|
int |
getPosition()
Returns the position of the context node.
|
int |
getSize()
Returns the size of the context.
|
XPathResult |
getVariable(java.lang.String name)
Returns the XPath result bound to the given variable name.
|
XPathContext |
newContext(NodeSet nodeSet,
int position)
Creates a new XPathContext with this XPathContext as it's
parent.
|
XPathContext |
newContext(XPathNode node)
Creates a new XPathContext with this XPathContext as it's
parent.
|
NodeSet |
newNodeSet()
Constructs and returns a new empty node-set.
|
NodeSet |
newNodeSet(int size)
Constructs and returns a new node-set with the specified size.
|
NodeSet |
newNodeSet(XPathNode node)
Constructs and returns a new node-set with one node.
|
void |
setNodeSet(NodeSet nodeSet,
int position)
Sets the given node-set as the context node-set for
this XPathContext
|
void |
setPosition(int position)
Sets the position of the context node within the context
node-set
|
public XPathContext(XPathNode node)
node - the context XPathNode.public XPathContext(XPathNode node, VariableSet variables)
node - the context XPathNode.variable - Variable bindings, or nullpublic XPathContext(VariableSet variables, NodeSet nodeSet, int position)
variable - Variable bindings, or nullnodeSet - the context node-set for this XPathContextposition - The position of the context node (zero base)public void addNamespaceBinding(java.lang.String prefix,
java.lang.String namespace)
prefix - the prefix to associate with the namespacenamespace - the namespace URI.public XPathNode getNode()
public int getPosition()
getSize()public int getSize()
public XPathContext newContext(XPathNode node)
public XPathContext newContext(NodeSet nodeSet, int position)
public NodeSet newNodeSet(int size)
size - The size of the node-setpublic NodeSet newNodeSet(XPathNode node)
node - The node to include in the node-setpublic NodeSet newNodeSet()
public NodeSet getNodeSet()
public void setNodeSet(NodeSet nodeSet, int position)
nodeSet - the node-set to use as the context node-set.position - the position of the context nodepublic int[] getDocumentOrder(XPathNode node)
public XPathNode getElementById(XPathNode root, java.lang.String id)
root - The root nodeid - The element's identifierpublic XPathResult getVariable(java.lang.String name)
name - The variable namepublic XPathFunction getFunction(java.lang.String uri, java.lang.String name)
uri - The function's namespace URIname - The function's name within that URIpublic java.lang.String getNamespaceURI(java.lang.String prefix)
prefix - the namespace prefixpublic void setPosition(int position)
the - position of the context node within the
context node-setjava.lang.IndexOutOfBoundsException - when the position
is not within the bounds of the context node-set.