Class Jaxp13XPathTemplate
- All Implemented Interfaces:
XPathOperations
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.
- Since:
- 1.0.0
- Author:
- Arjen Poutsma
- See Also:
-
Field Summary
Fields inherited from class org.springframework.xml.transform.TransformerObjectSupport
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> List<T>
evaluate
(String expression, Source context, NodeMapper<T> nodeMapper) Evaluates the given expression, mapping each resultNode
objects to a Java object via aNodeMapper
.boolean
evaluateAsBoolean
(String expression, Source context) Evaluates the given expression as aboolean
.double
evaluateAsDouble
(String expression, Source context) Evaluates the given expression as adouble
.evaluateAsNode
(String expression, Source context) Evaluates the given expression as aNode
.evaluateAsNodeList
(String expression, Source context) Evaluates the given expression as a list ofNode
objects.<T> T
evaluateAsObject
(String expression, Source context, NodeMapper<T> nodeMapper) Evaluates the given expression, mapping a singleNode
result to a Java object via aNodeMapper
.evaluateAsString
(String expression, Source context) Evaluates the given expression as aString
.Methods inherited from class org.springframework.xml.xpath.AbstractXPathTemplate
evaluate, getNamespaces, getRootElement, setNamespaces
Methods inherited from class org.springframework.xml.transform.TransformerObjectSupport
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
-
Constructor Details
-
Jaxp13XPathTemplate
public Jaxp13XPathTemplate() -
Jaxp13XPathTemplate
-
-
Method Details
-
evaluateAsBoolean
Description copied from interface:XPathOperations
Evaluates the given expression as aboolean
. Returns the boolean evaluation of the expression, orfalse
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 returnfalse
, while an expression that selects one or more nodes will returntrue
. An expression that returns a string returnsfalse
for empty strings andtrue
for all other strings. An expression that returns a number returnsfalse
for zero andtrue
for non-zero numbers.- Parameters:
expression
- the XPath expressioncontext
- the context starting point- Returns:
- the result of the evaluation
- Throws:
XPathException
- in case of XPath errors- See Also:
-
evaluateAsNode
Description copied from interface:XPathOperations
Evaluates the given expression as aNode
. Returns the evaluation of the expression, ornull
if it is invalid.- Parameters:
expression
- the XPath expressioncontext
- the context starting point- Returns:
- the result of the evaluation
- Throws:
XPathException
- in case of XPath errors- See Also:
-
evaluateAsNodeList
Description copied from interface:XPathOperations
Evaluates the given expression as a list ofNode
objects. Returns the evaluation of the expression, or an empty list if no results are found.- Parameters:
expression
- the XPath expressioncontext
- the context starting point- Returns:
- the result of the evaluation
- Throws:
XPathException
- in case of XPath errors- See Also:
-
evaluateAsDouble
Description copied from interface:XPathOperations
Evaluates the given expression as adouble
. Returns the evaluation of the expression, orDouble.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.- Parameters:
expression
- the XPath expressioncontext
- the context starting point- Returns:
- the result of the evaluation
- Throws:
XPathException
- in case of XPath errors- See Also:
-
evaluateAsString
Description copied from interface:XPathOperations
Evaluates the given expression as aString
. Returns the evaluation of the expression, ornull
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.- Parameters:
expression
- the XPath expressioncontext
- the context starting point- Returns:
- the result of the evaluation
- Throws:
XPathException
- in case of XPath errors- See Also:
-
evaluateAsObject
public <T> T evaluateAsObject(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException Description copied from interface:XPathOperations
Evaluates the given expression, mapping a singleNode
result to a Java object via aNodeMapper
.- Parameters:
expression
- the XPath expressioncontext
- the context starting pointnodeMapper
- object that will map one object per node- Returns:
- the single mapped object
- Throws:
XPathException
- in case of XPath errors- See Also:
-
evaluate
public <T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException Description copied from interface:XPathOperations
Evaluates the given expression, mapping each resultNode
objects to a Java object via aNodeMapper
.- Parameters:
expression
- the XPath expressioncontext
- the context starting pointnodeMapper
- object that will map one object per node- Returns:
- the result list, containing mapped objects
- Throws:
XPathException
- in case of XPath errors- See Also:
-