public class XPathEvaluator extends java.lang.Object
XPath
class as it has built-in support for namespace-handling and the
evaluation-method does not define exceptions.Constructor and Description |
---|
XPathEvaluator()
Create new evaluator.
|
Modifier and Type | Method and Description |
---|---|
void |
addNamespace(java.lang.String prefix,
java.lang.String uri)
Add a namespace.
|
java.lang.Object |
select(java.lang.String expr,
org.w3c.dom.Element context,
javax.xml.namespace.QName returnType)
Evaluates an XPath expression on context element.
|
boolean |
selectBoolean(java.lang.String expr,
org.w3c.dom.Element context)
Evaluates an XPath expression on context element.
|
double |
selectDouble(java.lang.String expr,
org.w3c.dom.Element context)
Evaluates an XPath expression on context element.
|
org.w3c.dom.Element |
selectElement(java.lang.String expr,
org.w3c.dom.Element context)
Evaluates an XPath expression on context element.
|
int |
selectInt(java.lang.String expr,
org.w3c.dom.Element context)
Evaluates an XPath expression on context element.
|
java.util.List<org.w3c.dom.Element> |
selectList(java.lang.String expr,
org.w3c.dom.Element context)
Evaluates an XPath expression on context element.
|
org.w3c.dom.NodeList |
selectNodeList(java.lang.String expr,
org.w3c.dom.Element context)
Evaluates an XPath expression on context element.
|
java.lang.String |
selectString(java.lang.String expr,
org.w3c.dom.Element context)
Evaluates an XPath expression on context element.
|
java.lang.Object |
selectUnsafe(java.lang.String expr,
org.w3c.dom.Element context,
javax.xml.namespace.QName returnType)
Evaluates an XPath expression on context element.
|
public XPathEvaluator()
public void addNamespace(java.lang.String prefix, java.lang.String uri)
public java.lang.Object select(java.lang.String expr, org.w3c.dom.Element context, javax.xml.namespace.QName returnType)
AssertionError
otherwise.returnType
- use XPathConstants
to define return type.public java.lang.Object selectUnsafe(java.lang.String expr, org.w3c.dom.Element context, javax.xml.namespace.QName returnType) throws javax.xml.xpath.XPathExpressionException
returnType
- use XPathConstants
to define return type.javax.xml.xpath.XPathExpressionException
- if the XPath expression is invalid.public java.util.List<org.w3c.dom.Element> selectList(java.lang.String expr, org.w3c.dom.Element context)
AssertionError
otherwise.public org.w3c.dom.NodeList selectNodeList(java.lang.String expr, org.w3c.dom.Element context)
AssertionError
otherwise.public org.w3c.dom.Element selectElement(java.lang.String expr, org.w3c.dom.Element context)
AssertionError
otherwise.public java.lang.String selectString(java.lang.String expr, org.w3c.dom.Element context)
AssertionError
otherwise.public double selectDouble(java.lang.String expr, org.w3c.dom.Element context)
AssertionError
otherwise.
Due to the implementation of XPath
this returns 0.0 if the
element was not found.public int selectInt(java.lang.String expr, org.w3c.dom.Element context)
AssertionError
otherwise.
Due to the implementation of XPath
this returns 0 if the element
was not found.public boolean selectBoolean(java.lang.String expr, org.w3c.dom.Element context)
AssertionError
otherwise.
Due to the implementation of XPath
this returns
false
if the element was not found.