public class Jaxp13XPathTemplate extends AbstractXPathTemplate
XPathOperations that uses JAXP 1.3. JAXP 1.3 is part of Java SE since 1.5.
Namespaces can be set using the namespaces property.
AbstractXPathTemplate.setNamespaces(java.util.Map)logger| Constructor and Description |
|---|
Jaxp13XPathTemplate() |
Jaxp13XPathTemplate(String xpathFactoryUri) |
| Modifier and Type | Method and Description |
|---|---|
<T> List<T> |
evaluate(String expression,
Source context,
NodeMapper<T> nodeMapper)
Evaluates the given expression, mapping each result
Node objects to a Java object via a NodeMapper. |
boolean |
evaluateAsBoolean(String expression,
Source context)
Evaluates the given expression as a
boolean. |
double |
evaluateAsDouble(String expression,
Source context)
Evaluates the given expression as a
double. |
Node |
evaluateAsNode(String expression,
Source context)
Evaluates the given expression as a
Node. |
List<Node> |
evaluateAsNodeList(String expression,
Source context)
Evaluates the given expression as a list of
Node objects. |
<T> T |
evaluateAsObject(String expression,
Source context,
NodeMapper<T> nodeMapper)
Evaluates the given expression, mapping a single
Node result to a Java object via a NodeMapper. |
String |
evaluateAsString(String expression,
Source context)
Evaluates the given expression as a
String. |
evaluate, getNamespaces, getRootElement, setNamespacescreateTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transformpublic Jaxp13XPathTemplate()
public Jaxp13XPathTemplate(String xpathFactoryUri)
public boolean evaluateAsBoolean(String expression, Source context) throws XPathException
XPathOperationsboolean. Returns the boolean evaluation of the expression, or
false if it is invalid.
The return value is determined per the boolean() function defined in the XPath specification.
This means that an expression that selects zero nodes will return false, while an expression that
selects one or more nodes will return true.
An expression that returns a string returns false for empty strings and true for all other
strings.
An expression that returns a number returns false for zero and true for non-zero numbers.
expression - the XPath expressioncontext - the context starting pointXPathException - in case of XPath errorspublic Node evaluateAsNode(String expression, Source context) throws XPathException
XPathOperationsNode. Returns the evaluation of the expression, or null
if it is invalid.expression - the XPath expressioncontext - the context starting pointXPathException - in case of XPath errorspublic List<Node> evaluateAsNodeList(String expression, Source context) throws XPathException
XPathOperationsNode objects. Returns the evaluation of the expression, or an
empty list if no results are found.expression - the XPath expressioncontext - the context starting pointXPathException - in case of XPath errorspublic double evaluateAsDouble(String expression, Source context) throws XPathException
XPathOperationsdouble. Returns the evaluation of the expression, or Double.NaN if it is invalid.
The return value is determined per the number() function as defined in the XPath specification.
This means that if the expression selects multiple nodes, it will return the number value of the first node.
expression - the XPath expressioncontext - the context starting pointXPathException - in case of XPath errorspublic String evaluateAsString(String expression, Source context) throws XPathException
XPathOperationsString. Returns the evaluation of the expression, or
null if it is invalid.
The return value is determined per the string() function as defined in the XPath specification.
This means that if the expression selects multiple nodes, it will return the string value of the first node.
expression - the XPath expressioncontext - the context starting pointXPathException - in case of XPath errorspublic <T> T evaluateAsObject(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException
XPathOperationsNode result to a Java object via a NodeMapper.expression - the XPath expressioncontext - the context starting pointnodeMapper - object that will map one object per nodeXPathException - in case of XPath errorspublic <T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException
XPathOperationsNode objects to a Java object via a NodeMapper.expression - the XPath expressioncontext - the context starting pointnodeMapper - object that will map one object per nodeXPathException - in case of XPath errors