| java.lang.Object net.sf.saxon.xpath.XPathExpressionImpl
XPathExpressionImpl | public class XPathExpressionImpl implements XPathExpression(Code) | | The JAXP XPathExpression interface represents a compiled XPath expression that can be repeatedly
evaluated. This class is Saxon's implementation of that interface.
The class also includes some methods retained from Saxon's original XPath API. When these methods
are used, the object contains the context node and other state, so it is not thread-safe.
author: Michael H. Kay |
Method Summary | |
public List | evaluate() Execute a prepared XPath expression, returning the results as a List. | public Object | evaluate(Object node, QName qName) JAXP 1.3 evaluate() method
Parameters: node - The context node. | public String | evaluate(Object node) Evaluate the expression to return a string value
Parameters: node - the initial context node. | public Object | evaluate(InputSource inputSource, QName qName) Evaluate the XPath expression against an input source to obtain a result of a specified type
Parameters: inputSource - The input source document against which the expression is evaluated.(Note that there is no caching. | public String | evaluate(InputSource inputSource) Evaluate the XPath expression against an input source to obtain a string result
Parameters: inputSource - The input source document against which the expression is evaluated.(Note that there is no caching. | public Object | evaluateSingle() Execute a prepared XPath expression, returning the first item in the result.
This is useful where it is known that the expression will only return
a singleton value (for example, a single node, or a boolean). | public Expression | getInternalExpression() Low-level method to get the internal Saxon expression object. | public SequenceIterator | rawIterator() Get a raw iterator over the results of the expression. | public void | setContextNode(NodeInfo node) Set the context node for evaluating the expression. | public void | setSortKey(XPathExpressionImpl sortKey) Define the sort order for the results of the expression. | protected void | setStackFrameMap(SlotManager map) Define the number of slots needed for local variables within the expression. |
XPathExpressionImpl | protected XPathExpressionImpl(Expression exp, Configuration config)(Code) | | The constructor is protected, to ensure that instances can only be
created using the createExpression() method of XPathEvaluator
|
evaluate | public Object evaluate(Object node, QName qName) throws XPathExpressionException(Code) | | JAXP 1.3 evaluate() method
Parameters: node - The context node. This must use a representation of nodes that this implementation understands.This may be a Saxon NodeInfo, or a node in one of the external object models supported, for exampleDOM, JDOM, or XOM, provided the support module for that object model is loaded. Parameters: qName - Indicates the type of result required. This must be one of the constants defined inthe JAXP XPathConstants class.Saxon will attempt to convert the actual result of the expression to the required type using theXPath 1.0 conversion rules. the result of the evaluation, as a Java object of the appropriate type. Saxon interprets therules as follows:QName | Return Value | BOOLEAN | The effective boolean value of the actual result,as a Java Boolean object | STRING | The result of applying the string() function to the actual result,as a Java String object | NUMBER | The result of applying the number() function to the actual result,as a Java Double object | NODE | A single node, in the native data model supplied as input. If theexpression returns more than one node, the first is returned. Ifthe expression returns an empty sequence, null is returned. If theexpression returns an atomic value, or if the first item in theresult sequence is an atomic value, an exception is thrown. | NODESET | This is interpreted as allowing any sequence, of nodes or atomic values.The result is returned as a Java List object, unless it is empty, in whichcase null is returned. The contents of the list may be node objects (in thenative data model supplied as input, or Java objects representing the XPathatomic values in the actual result: String for an xs:string, Double for a xs:double,Long for an xs:integer, and so on. (For safety, cast the values to a typesuch as xs:string within the XPath expression). Note that the result is neverreturned as a DOM NodeList. |
throws: XPathExpressionException - if evaluation of the expression fails or if theresult cannot be converted to the requested type. |
evaluate | public String evaluate(InputSource inputSource) throws XPathExpressionException(Code) | | Evaluate the XPath expression against an input source to obtain a string result
Parameters: inputSource - The input source document against which the expression is evaluated.(Note that there is no caching. This will be parsed, and the parsed result will be discarded.) the result of the evaluation, converted to a String throws: XPathExpressionException - |
evaluateSingle | public Object evaluateSingle() throws XPathException(Code) | | Execute a prepared XPath expression, returning the first item in the result.
This is useful where it is known that the expression will only return
a singleton value (for example, a single node, or a boolean). The context node
must be set previously using
XPathExpressionImpl.setContextNode(net.sf.saxon.om.NodeInfo) .
The first item in the sequence returned by the expression. If the expressionreturns an empty sequence, this method returns null. Otherwise, it returns the firstitem in the result sequence, represented as a Java object using the same mapping as forthe evaluate() method |
getInternalExpression | public Expression getInternalExpression()(Code) | | Low-level method to get the internal Saxon expression object. This exposes a wide range of
internal methods that may be needed by specialized applications, and allows greater control
over the dynamic context for evaluating the expression.
the underlying Saxon expression object. |
rawIterator | public SequenceIterator rawIterator() throws XPathException(Code) | | Get a raw iterator over the results of the expression. This returns results without
any conversion of the returned items to "native" Java classes. This method is intended
for use by applications that need to process the results of the expression using
internal Saxon interfaces.
|
setContextNode | public void setContextNode(NodeInfo node)(Code) | | Set the context node for evaluating the expression. If this method is not called,
the context node will be the root of the document to which the prepared expression is
bound.
|
setSortKey | public void setSortKey(XPathExpressionImpl sortKey)(Code) | | Define the sort order for the results of the expression. If this method is called, then
the list returned by a subsequent call on the evaluate() method will first be sorted.
Parameters: sortKey - an XPathExpression, which will be applied to each item in the sequence;the result of this expression determines the ordering of the list returned by the evaluate()method. The sortKey can be null, to clear a previous sort key. |
setStackFrameMap | protected void setStackFrameMap(SlotManager map)(Code) | | Define the number of slots needed for local variables within the expression.
This method is for internal use only.
|
|
|