|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.xpath.XPathEvaluator
XPathEvaluator provides a simple API for standalone XPath processing (that is, executing XPath expressions in the absence of an XSLT stylesheet). It is loosely modelled on the proposed org.w3c.dom.xpath.XPathEvaluator interface, though it does not actually implement this interface at present.
Constructor Summary | |
XPathEvaluator()
Default constructor. |
|
XPathEvaluator(Source source)
Construct an XPathEvaluator to process a particular source document. |
Method Summary | |
static Object |
convert(Item item)
Internal method to convert an XPath value to a Java object. |
XPathExpression |
createExpression(String expression)
Prepare an XPath expression for subsequent evaluation. |
List |
evaluate(String expression)
Prepare and execute an XPath expression, supplied as a string, and returning the results as a List. |
Object |
evaluateSingle(String expression)
Prepare and execute an XPath expression, supplied as a string, and returning the first item in the result. |
StaticContext |
getStaticContext()
Get the current static context |
static void |
main(String[] args)
A simple command-line interface for the XPathEvaluator (not documented). |
void |
setContextNode(NodeInfo node)
Set the context node. |
NodeInfo |
setSource(Source source)
Supply the document against which XPath expressions are to be executed. |
void |
setStaticContext(StaticContext context)
Set the static context for compiling XPath expressions. |
void |
setStripSpace(boolean strip)
Indicate whether all whitespace text nodes in the source document are to be removed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XPathEvaluator()
public XPathEvaluator(Source source) throws XPathException
source
- The source document (or a specific node within it).Method Detail |
public void setStripSpace(boolean strip)
strip
- True if all whitespace text nodes are to be stripped from the source document,
false otherwise. The default if the method is not called is false.public NodeInfo setSource(Source source) throws XPathException
source
- Any javax.xml.transform.Source object representing the document against
which XPath expressions will be executed. Note that a Saxon DocumentInfo (indeed any NodeInfo)
can be used as a Source. To use a third-party DOM Document as a source, create an instance of
javax.xml.transform.dom.DOMSource to wrap it. Note that this method copies the supplied
DOM to a TinyTree; if you want instead to wrap the DOM in a NodeInfo layer, use
setSource(new DocumentWrapper(dom)).
The Source object supplied also determines the initial setting
of the context item. In most cases the context node will be the root of the supplied document;
however, if a NodeInfo or DOMSource is supplied it can be any node in the document.
XPathException
public void setStaticContext(StaticContext context)
public StaticContext getStaticContext()
public XPathExpression createExpression(String expression) throws XPathException
expression
- The XPath expression to be evaluated, supplied as a string.
XPathException
- if the syntax of the expression is wrong, or if it references namespaces,
variables, or functions that have not been declared.public void setContextNode(NodeInfo node)
node
- The node to be used as the context node. This must
be a node within the context document (the document supplied using the setSource() method).
NullPointerException
- if the argument is null
IllegalArgumentException
- if the supplied node is not a node in the context documentpublic List evaluate(String expression) throws XPathException
expression
- The XPath expression to be evaluated, supplied as a string.
XPathException
public static Object convert(Item item) throws XPathException
XPathException
public Object evaluateSingle(String expression) throws XPathException
expression
- The XPath expression to be evaluated, supplied as a string.
XPathException
public static void main(String[] args) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |