use of javax.xml.xpath.XPathVariableResolver in project jstl-api by eclipse-ee4j.
the class JSTLNodeList method selectNodes.
/**
* Evaluate an XPath expression to a List of nodes.
*/
public List<Object> selectNodes(Node contextNode, String xpathString) throws JspTagException {
XPathVariableResolver jxvr = new JSTLXPathVariableResolver(pageContext);
try {
XPath xpath = XPATH_FACTORY.newXPath();
xpath.setNamespaceContext(jstlXPathNamespaceContext);
xpath.setXPathVariableResolver(jxvr);
Object nl = xpath.evaluate(xpathString, contextNode, JSTLXPathConstants.OBJECT);
return new JSTLNodeList(nl);
} catch (XPathExpressionException ex) {
throw new JspTagException(ex.toString(), ex);
}
}
use of javax.xml.xpath.XPathVariableResolver in project jstl-api by eclipse-ee4j.
the class JSTLNodeList method selectSingleNode.
/**
* Evaluate an XPath expression to a single node.
*/
public Node selectSingleNode(Node contextNode, String xpathString) throws JspTagException {
// p("selectSingleNode of XPathUtil = passed node:" +
// "xpathString => " + n + " : " + xpathString );
XPathVariableResolver jxvr = new JSTLXPathVariableResolver(pageContext);
try {
XPath xpath = XPATH_FACTORY.newXPath();
xpath.setNamespaceContext(jstlXPathNamespaceContext);
xpath.setXPathVariableResolver(jxvr);
return (Node) xpath.evaluate(xpathString, contextNode, XPathConstants.NODE);
} catch (XPathExpressionException ex) {
throw new JspTagException(ex.toString(), ex);
}
}
use of javax.xml.xpath.XPathVariableResolver in project jstl-api by eclipse-ee4j.
the class JSTLNodeList method booleanValueOf.
/**
* Evaluate an XPath expression to a boolean value.
*/
public boolean booleanValueOf(Node contextNode, String xpathString) throws JspTagException {
XPathVariableResolver jxvr = new JSTLXPathVariableResolver(pageContext);
XPath xpath = XPATH_FACTORY.newXPath();
xpath.setNamespaceContext(jstlXPathNamespaceContext);
xpath.setXPathVariableResolver(jxvr);
try {
return ((Boolean) xpath.evaluate(xpathString, contextNode, XPathConstants.BOOLEAN)).booleanValue();
} catch (XPathExpressionException ex) {
throw new JspTagException(Resources.getMessage("XPATH_ERROR_XOBJECT", ex.toString()), ex);
}
}
Aggregations