* #### reset
void reset()
* #### setXPathVariableResolver
void setXPathVariableResolver([XPathVariableResolver](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.base/java/lang/NullPointerException.html "class in java.lang")` \- If `resolver` is `null`.
* #### getXPathVariableResolver
[XPathVariableResolver](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](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.base/java/lang/NullPointerException.html "class in java.lang")` \- If `resolver` is `null`.
* #### getXPathFunctionResolver
[XPathFunctionResolver](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](../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.base/java/lang/NullPointerException.html "class in java.lang")` \- If `nsContext` is `null`.
* #### getNamespaceContext
[NamespaceContext](../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](XPathExpression.html "interface in javax.xml.xpath") compile([String](../../../../java.base/java/lang/String.html "class in java.lang") expression)
throws [XPathExpressionException](XPathExpressionException.html "class in javax.xml.xpath")
Parameters:
`expression` \- The XPath expression.
Returns:
Compiled XPath expression.
Throws:
`[XPathExpressionException](XPathExpressionException.html "class in javax.xml.xpath")` \- If `expression` cannot be compiled.
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression` is `null`.
* #### evaluate
[Object](../../../../java.base/java/lang/Object.html "class in java.lang") evaluate([String](../../../../java.base/java/lang/String.html "class in java.lang") expression,
[Object](../../../../java.base/java/lang/Object.html "class in java.lang") item,
[QName](../namespace/QName.html "class in javax.xml.namespace") returnType)
throws [XPathExpressionException](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](XPathExpressionException.html "class in javax.xml.xpath")` \- If `expression` cannot be evaluated.
`[IllegalArgumentException](../../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")` \- If `returnType` is not one of the types defined in [XPathConstants](XPathConstants.html "class in javax.xml.xpath") ([NUMBER](XPathConstants.html#NUMBER),[STRING](XPathConstants.html#STRING),[BOOLEAN](XPathConstants.html#BOOLEAN),[NODE](XPathConstants.html#NODE) or[NODESET](XPathConstants.html#NODESET)).
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression or returnType` is `null`.
* #### evaluate
[String](../../../../java.base/java/lang/String.html "class in java.lang") evaluate([String](../../../../java.base/java/lang/String.html "class in java.lang") expression,
[Object](../../../../java.base/java/lang/Object.html "class in java.lang") item)
throws [XPathExpressionException](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)](#evaluate%28java.lang.String,java.lang.Object,javax.xml.namespace.QName%29) with a `returnType` of[XPathConstants.STRING](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](XPathExpressionException.html "class in javax.xml.xpath")` \- If `expression` cannot be evaluated.
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression` is `null`.
* #### evaluate
[Object](../../../../java.base/java/lang/Object.html "class in java.lang") evaluate([String](../../../../java.base/java/lang/String.html "class in java.lang") expression,
[InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") source,
[QName](../namespace/QName.html "class in javax.xml.namespace") returnType)
throws [XPathExpressionException](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)](#evaluate%28java.lang.String,java.lang.Object,javax.xml.namespace.QName%29) 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](XPathExpressionException.html "class in javax.xml.xpath")` \- If expression cannot be evaluated.
`[IllegalArgumentException](../../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")` \- If `returnType` is not one of the types defined in [XPathConstants](XPathConstants.html "class in javax.xml.xpath").
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression, source or returnType` is `null`.
* #### evaluate
[String](../../../../java.base/java/lang/String.html "class in java.lang") evaluate([String](../../../../java.base/java/lang/String.html "class in java.lang") expression,
[InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") source)
throws [XPathExpressionException](XPathExpressionException.html "class in javax.xml.xpath")
Evaluate an XPath expression in the context of the specified `InputSource` and return the result as a `String`.
This method calls [evaluate(String expression, InputSource source, QName returnType)](#evaluate%28java.lang.String,org.xml.sax.InputSource,javax.xml.namespace.QName%29) with a`returnType` of [XPathConstants.STRING](XPathConstants.html#STRING).
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 `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](XPathExpressionException.html "class in javax.xml.xpath")` \- If expression cannot be evaluated.
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression or source` is `null`.
* #### evaluateExpression
default <T> T evaluateExpression([String](../../../../java.base/java/lang/String.html "class in java.lang") expression,
[Object](../../../../java.base/java/lang/Object.html "class in java.lang") item,
[Class](../../../../java.base/java/lang/Class.html "class in java.lang")<T> type)
throws [XPathExpressionException](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](XPathEvaluationResult.XPathResultType.html#ANY) type, specifying XPathEvaluationResult as the type will result in IllegalArgumentException. Any implementation supporting the[ANY](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](XPathExpressionException.html "class in javax.xml.xpath")` \- If the expression cannot be evaluated.
`[IllegalArgumentException](../../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")` \- If `type` is not of the types corresponding to the types defined in the [XPathEvaluationResult.XPathResultType](XPathEvaluationResult.XPathResultType.html "enum in javax.xml.xpath"), or XPathEvaluationResult is specified as the type but an implementation supporting the[ANY](XPathEvaluationResult.XPathResultType.html#ANY) type is not available.
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression or type` is `null`.
Since:
9
* #### evaluateExpression
default [XPathEvaluationResult](XPathEvaluationResult.html "interface in javax.xml.xpath")<?> evaluateExpression([String](../../../../java.base/java/lang/String.html "class in java.lang") expression,
[Object](../../../../java.base/java/lang/Object.html "class in java.lang") item)
throws [XPathExpressionException](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)](#evaluateExpression%28java.lang.String,java.lang.Object,java.lang.Class%29) with type [XPathEvaluationResult](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](XPathEvaluationResult.XPathResultType.html#ANY) type, the default implementation of this method will always throw an IllegalArgumentException. Any implementation supporting the[ANY](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](XPathExpressionException.html "class in javax.xml.xpath")` \- If the expression cannot be evaluated.
`[IllegalArgumentException](../../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")` \- If the implementation of this method does not support the[ANY](XPathEvaluationResult.XPathResultType.html#ANY) type.
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression` is `null`.
Since:
9
* #### evaluateExpression
default <T> T evaluateExpression([String](../../../../java.base/java/lang/String.html "class in java.lang") expression,
[InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") source,
[Class](../../../../java.base/java/lang/Class.html "class in java.lang")<T> type)
throws [XPathExpressionException](XPathExpressionException.html "class in javax.xml.xpath")
Evaluate an XPath expression in the context of the specified `source` and return the result as specified.
This method builds a data model for the [InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") and calls[evaluateExpression(String expression, Object item, Class type)](#evaluateExpression%28java.lang.String,java.lang.Object,java.lang.Class%29) on the resulting document object. The data model is usually[Document](../../../org/w3c/dom/Document.html "interface in org.w3c.dom")
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](XPathEvaluationResult.XPathResultType.html#ANY) type, specifying XPathEvaluationResult as the type will result in IllegalArgumentException. Any implementation supporting the[ANY](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](XPathExpressionException.html "class in javax.xml.xpath")` \- If the expression cannot be evaluated.
`[IllegalArgumentException](../../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")` \- If `type` is not of the types corresponding to the types defined in the [XPathResultType](XPathEvaluationResult.XPathResultType.html "enum in javax.xml.xpath"), or XPathEvaluationResult is specified as the type but an implementation supporting the[ANY](XPathEvaluationResult.XPathResultType.html#ANY) type is not available.
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression, source or type`is `null`.
Since:
9
* #### evaluateExpression
default [XPathEvaluationResult](XPathEvaluationResult.html "interface in javax.xml.xpath")<?> evaluateExpression([String](../../../../java.base/java/lang/String.html "class in java.lang") expression,
[InputSource](../../../org/xml/sax/InputSource.html "class in org.xml.sax") source)
throws [XPathExpressionException](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)](#evaluateExpression%28java.lang.String,java.lang.Object,java.lang.Class%29) with type [XPathEvaluationResult](XPathEvaluationResult.html "interface in javax.xml.xpath"):
`
evaluateExpression(expression, item, XPathEvaluationResult.class);
`
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](XPathEvaluationResult.XPathResultType.html#ANY) type, the default implementation of this method will always throw an IllegalArgumentException. Any implementation supporting the[ANY](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](XPathExpressionException.html "class in javax.xml.xpath")` \- If the expression cannot be evaluated.
`[IllegalArgumentException](../../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")` \- If the implementation of this method does not support the[ANY](XPathEvaluationResult.XPathResultType.html#ANY) type.
`[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- If `expression or source` is `null`.
Since:
9