public class XPathEvaluator extends Object implements XPathVariableResolver
Each instance accepts one XPath expression and keeps a compiled version of it for better performance.
This evaluator is reusable, as long as the reset() method is invoked in between evaluations. It is not thread-safe
though.
It also implements the XPathVariableResolver interface in order to bind contextProperties to variables defined
in the XPath script.
| Constructor and Description |
|---|
XPathEvaluator(String expression,
XPathFactory xpathFactory,
Collection<NamespaceMapping> namespaces)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
List<String> |
evaluate(Node input,
Map<String,Object> contextProperties)
Evaluates the expression on the
input node, using the given contextProperties. |
XPathEvaluator |
keepingTrailingNewlines(boolean shouldKeepTrailingNewlines) |
void |
reset()
Invoke this method in between invocations of the
evaluate(Node, Map) method in order to reuse this instance |
Object |
resolveVariable(QName variableName)
Resolves the given variable against the context properties passed on the
evaluate(Node, Map) method |
public XPathEvaluator(String expression, XPathFactory xpathFactory, Collection<NamespaceMapping> namespaces)
expression - the xpath expressionxpathFactory - the XPathFactory used to compile the expressionnamespaces - namespace mappingspublic List<String> evaluate(Node input, Map<String,Object> contextProperties)
input node, using the given contextProperties.
After invoking this method, the consumer MUST invoke the reset() method in order to reuse this evaluator.
input - the base node of the evaluationcontextProperties - context propertiespublic Object resolveVariable(QName variableName)
evaluate(Node, Map) methodresolveVariable in interface XPathVariableResolvervariableName - the variable namenullpublic void reset()
evaluate(Node, Map) method in order to reuse this instancepublic XPathEvaluator keepingTrailingNewlines(boolean shouldKeepTrailingNewlines)
Copyright © 2026 MuleSoft, Inc.. All rights reserved.