|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.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(javax.xml.transform.Source source)
Construct an XPathEvaluator to process a particular source document. |
Method Summary | |
static java.lang.Object |
convert(Item item)
Internal method to convert an XPath value to a Java object. |
XPathExpression |
createExpression(java.lang.String expression)
Prepare an XPath expression for subsequent evaluation. |
java.util.List |
evaluate(java.lang.String expression)
Prepare and execute an XPath expression, supplied as a string, and returning the results as a List. |
java.lang.Object |
evaluateSingle(java.lang.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(java.lang.String[] args)
A simple command-line interface for the XPathEvaluator (not documented). |
void |
setContextNode(NodeInfo node)
Set the context node. |
NodeInfo |
setSource(javax.xml.transform.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(javax.xml.transform.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(javax.xml.transform.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
DOMSource
to wrap it.
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(java.lang.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).
java.lang.NullPointerException
- if the argument is null
java.lang.IllegalArgumentException
- if the supplied node is not a node in the context documentpublic java.util.List evaluate(java.lang.String expression) throws XPathException
expression
- The XPath expression to be evaluated, supplied as a string.
XPathException
public static java.lang.Object convert(Item item) throws XPathException
XPathException
public java.lang.Object evaluateSingle(java.lang.String expression) throws XPathException
expression
- The XPath expression to be evaluated, supplied as a string.
XPathException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |