* #### reset
void reset()
* #### setXPathVariableResolver
void setXPathVariableResolver([XPathVariableResolver](../../../javax/xml/xpath/XPathVariableResolver.html "interface in javax.xml.xpath") resolver)
Establish a variable resolver.
A `NullPointerException` is thrown if `resolver` is `null`.
Parameters:
`resolver` \- Variable resolver.
Throws:
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `resolver` is `null`.
* #### getXPathVariableResolver
[XPathVariableResolver](../../../javax/xml/xpath/XPathVariableResolver.html "interface in javax.xml.xpath") getXPathVariableResolver()
Return the current variable resolver.
`null` is returned in no variable resolver is in effect.
Returns:
Current variable resolver.
* #### setXPathFunctionResolver
void setXPathFunctionResolver([XPathFunctionResolver](../../../javax/xml/xpath/XPathFunctionResolver.html "interface in javax.xml.xpath") resolver)
Establish a function resolver.
A `NullPointerException` is thrown if `resolver` is `null`.
Parameters:
`resolver` \- XPath function resolver.
Throws:
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `resolver` is `null`.
* #### getXPathFunctionResolver
[XPathFunctionResolver](../../../javax/xml/xpath/XPathFunctionResolver.html "interface in javax.xml.xpath") getXPathFunctionResolver()
Return the current function resolver.
`null` is returned in no function resolver is in effect.
Returns:
Current function resolver.
* #### setNamespaceContext
void setNamespaceContext([NamespaceContext](../../../javax/xml/namespace/NamespaceContext.html "interface in javax.xml.namespace") nsContext)
Establish a namespace context.
A `NullPointerException` is thrown if `nsContext` is `null`.
Parameters:
`nsContext` \- Namespace context to use.
Throws:
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `nsContext` is `null`.
* #### getNamespaceContext
[NamespaceContext](../../../javax/xml/namespace/NamespaceContext.html "interface in javax.xml.namespace") getNamespaceContext()
Return the current namespace context.
`null` is returned in no namespace context is in effect.
Returns:
Current Namespace context.
* #### compile
[XPathExpression](../../../javax/xml/xpath/XPathExpression.html "interface in javax.xml.xpath") compile([String](../../../java/lang/String.html "class in java.lang") expression)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Parameters:
`expression` \- The XPath expression.
Returns:
Compiled XPath expression.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If `expression` cannot be compiled.
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression` is `null`.
* #### evaluate
[Object](../../../java/lang/Object.html "class in java.lang") evaluate([String](../../../java/lang/String.html "class in java.lang") expression,
[Object](../../../java/lang/Object.html "class in java.lang") item,
[QName](../../../javax/xml/namespace/QName.html "class in javax.xml.namespace") returnType)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Evaluate an `XPath` expression in the specified context and return the result as the specified type.
See [Evaluation of XPath Expressions](#XPath-evaluation) for context item evaluation, variable, function and `QName` resolution and return type conversion.
The parameter `item` represents the context the XPath expression will be operated on. The type of the context is implementation-dependent. If the value is `null`, the operation must have no dependency on the context, otherwise an XPathExpressionException will be thrown.
Implementation Note:
The type of the context is usually [Node](../../../org/w3c/dom/Node.html "interface in org.w3c.dom").
Parameters:
`expression` \- The XPath expression.
`item` \- The context the XPath expression will be evaluated in.
`returnType` \- The result type expected to be returned by the XPath expression.
Returns:
The result of evaluating an XPath expression as an `Object` of `returnType`.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If `expression` cannot be evaluated.
`[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- If `returnType` is not one of the types defined in [XPathConstants](../../../javax/xml/xpath/XPathConstants.html "class in javax.xml.xpath") ([NUMBER](../../../javax/xml/xpath/XPathConstants.html#NUMBER),[STRING](../../../javax/xml/xpath/XPathConstants.html#STRING),[BOOLEAN](../../../javax/xml/xpath/XPathConstants.html#BOOLEAN),[NODE](../../../javax/xml/xpath/XPathConstants.html#NODE) or[NODESET](../../../javax/xml/xpath/XPathConstants.html#NODESET)).
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression or returnType` is `null`.
* #### evaluate
[String](../../../java/lang/String.html "class in java.lang") evaluate([String](../../../java/lang/String.html "class in java.lang") expression,
[Object](../../../java/lang/Object.html "class in java.lang") item)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Evaluate an XPath expression in the specified context and return the result as a `String`.
This method calls [evaluate(String expression, Object item, QName returnType)](../../../javax/xml/xpath/XPath.html#evaluate-java.lang.String-java.lang.Object-javax.xml.namespace.QName-) with a `returnType` of[XPathConstants.STRING](../../../javax/xml/xpath/XPathConstants.html#STRING).
See [Evaluation of XPath Expressions](#XPath-evaluation) for context item evaluation, variable, function and QName resolution and return type conversion.
The parameter `item` represents the context the XPath expression will be operated on. The type of the context is implementation-dependent. If the value is `null`, the operation must have no dependency on the context, otherwise an XPathExpressionException will be thrown.
Implementation Note:
The type of the context is usually [Node](../../../org/w3c/dom/Node.html "interface in org.w3c.dom").
Parameters:
`expression` \- The XPath expression.
`item` \- The context the XPath expression will be evaluated in.
Returns:
The result of evaluating an XPath expression as a `String`.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If `expression` cannot be evaluated.
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression` is `null`.
* #### evaluate
[Object](../../../java/lang/Object.html "class in java.lang") evaluate([String](../../../java/lang/String.html "class in java.lang") expression,
[InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") source,
[QName](../../../javax/xml/namespace/QName.html "class in javax.xml.namespace") returnType)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Evaluate an XPath expression in the context of the specified `InputSource` and return the result as the specified type.
This method builds a data model for the [InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") and calls[evaluate(String expression, Object item, QName returnType)](../../../javax/xml/xpath/XPath.html#evaluate-java.lang.String-java.lang.Object-javax.xml.namespace.QName-) on the resulting document object.
See [Evaluation of XPath Expressions](#XPath-evaluation) for context item evaluation, variable, function and QName resolution and return type conversion.
Parameters:
`expression` \- The XPath expression.
`source` \- The input source of the document to evaluate over.
`returnType` \- The desired return type.
Returns:
The `Object` that encapsulates the result of evaluating the expression.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If expression cannot be evaluated.
`[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- If `returnType` is not one of the types defined in [XPathConstants](../../../javax/xml/xpath/XPathConstants.html "class in javax.xml.xpath").
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression, source or returnType` is `null`.
* #### evaluate
[String](../../../java/lang/String.html "class in java.lang") evaluate([String](../../../java/lang/String.html "class in java.lang") expression,
[InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") source)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Parameters:
`expression` \- The XPath expression.
`source` \- The `InputSource` of the document to evaluate over.
Returns:
The `String` that is the result of evaluating the expression and converting the result to a `String`.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If expression cannot be evaluated.
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression or source` is `null`.
* #### evaluateExpression
default <T> T evaluateExpression([String](../../../java/lang/String.html "class in java.lang") expression,
[Object](../../../java/lang/Object.html "class in java.lang") item,
[Class](../../../java/lang/Class.html "class in java.lang")<T> type)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Evaluate an XPath expression in the specified context and return the result with the type specified through the `class type`
The parameter `item` represents the context the XPath expression will be operated on. The type of the context is implementation-dependent. If the value is `null`, the operation must have no dependency on the context, otherwise an XPathExpressionException will be thrown.
Implementation Requirements:
The default implementation in the XPath API is equivalent to:
`
(T)evaluate(expression, item,
XPathEvaluationResult.XPathResultType.getQNameType(type));
`
Since the `evaluate` method does not support the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type, specifying XPathEvaluationResult as the type will result in IllegalArgumentException. Any implementation supporting the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type must override this method.
Implementation Note:
The type of the context is usually [Node](../../../org/w3c/dom/Node.html "interface in org.w3c.dom").
Type Parameters:
`T` \- The class type that will be returned by the XPath expression.
Parameters:
`expression` \- The XPath expression.
`item` \- The context the XPath expression will be evaluated in.
`type` \- The class type expected to be returned by the XPath expression.
Returns:
The result of evaluating the expression.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If the expression cannot be evaluated.
`[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- If `type` is not of the types corresponding to the types defined in the [XPathEvaluationResult.XPathResultType](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html "enum in javax.xml.xpath"), or XPathEvaluationResult is specified as the type but an implementation supporting the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type is not available.
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression or type` is `null`.
Since:
9
* #### evaluateExpression
default [XPathEvaluationResult](../../../javax/xml/xpath/XPathEvaluationResult.html "interface in javax.xml.xpath")<?> evaluateExpression([String](../../../java/lang/String.html "class in java.lang") expression,
[Object](../../../java/lang/Object.html "class in java.lang") item)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Evaluate an XPath expression in the specified context. This is equivalent to calling [evaluateExpression(String expression, Object item, Class type)](../../../javax/xml/xpath/XPath.html#evaluateExpression-java.lang.String-java.lang.Object-java.lang.Class-) with type [XPathEvaluationResult](../../../javax/xml/xpath/XPathEvaluationResult.html "interface in javax.xml.xpath"):
`
evaluateExpression(expression, item, XPathEvaluationResult.class);
`
The parameter `item` represents the context the XPath expression will be operated on. The type of the context is implementation-dependent. If the value is `null`, the operation must have no dependency on the context, otherwise an XPathExpressionException will be thrown.
Implementation Requirements:
The default implementation in the XPath API is equivalent to:
`
evaluateExpression(expression, item, XPathEvaluationResult.class);
`
Since the `evaluate` method does not support the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type, the default implementation of this method will always throw an IllegalArgumentException. Any implementation supporting the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type must therefore override this method.
Implementation Note:
The type of the context is usually [Node](../../../org/w3c/dom/Node.html "interface in org.w3c.dom").
Parameters:
`expression` \- The XPath expression.
`item` \- The context the XPath expression will be evaluated in.
Returns:
The result of evaluating the expression.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If the expression cannot be evaluated.
`[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- If the implementation of this method does not support the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type.
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression` is `null`.
Since:
9
* #### evaluateExpression
default <T> T evaluateExpression([String](../../../java/lang/String.html "class in java.lang") expression,
[InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") source,
[Class](../../../java/lang/Class.html "class in java.lang")<T> type)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Implementation Requirements:
The default implementation in the XPath API is equivalent to:
`
(T)evaluate(expression, source,
XPathEvaluationResult.XPathResultType.getQNameType(type));
`
Since the `evaluate` method does not support the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type, specifying XPathEvaluationResult as the type will result in IllegalArgumentException. Any implementation supporting the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type must override this method.
Type Parameters:
`T` \- The class type that will be returned by the XPath expression.
Parameters:
`expression` \- The XPath expression.
`source` \- The input source of the document to evaluate over.
`type` \- The class type expected to be returned by the XPath expression.
Returns:
The result of evaluating the expression.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If the expression cannot be evaluated.
`[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- If `type` is not of the types corresponding to the types defined in the [XPathResultType](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html "enum in javax.xml.xpath"), or XPathEvaluationResult is specified as the type but an implementation supporting the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type is not available.
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression, source or type`is `null`.
Since:
9
* #### evaluateExpression
default [XPathEvaluationResult](../../../javax/xml/xpath/XPathEvaluationResult.html "interface in javax.xml.xpath")<?> evaluateExpression([String](../../../java/lang/String.html "class in java.lang") expression,
[InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") source)
throws [XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")
Implementation Requirements:
The default implementation in the XPath API is equivalent to:
`
evaluateExpression(expression, source, XPathEvaluationResult.class);
`
Since the `evaluate` method does not support the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type, the default implementation of this method will always throw an IllegalArgumentException. Any implementation supporting the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type must therefore override this method.
Parameters:
`expression` \- The XPath expression.
`source` \- The input source of the document to evaluate over.
Returns:
The result of evaluating the expression.
Throws:
`[XPathExpressionException](../../../javax/xml/xpath/XPathExpressionException.html "class in javax.xml.xpath")` \- If the expression cannot be evaluated.
`[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- If the implementation of this method does not support the[ANY](../../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html#ANY) type.
`[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `expression or source` is `null`.
Since:
9