Search in sources :

Example 6 with XPathVariableResolver

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);
    }
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpressionException(javax.xml.xpath.XPathExpressionException) XPathVariableResolver(javax.xml.xpath.XPathVariableResolver) JspTagException(jakarta.servlet.jsp.JspTagException)

Example 7 with XPathVariableResolver

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);
    }
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Node(org.w3c.dom.Node) XPathVariableResolver(javax.xml.xpath.XPathVariableResolver) JspTagException(jakarta.servlet.jsp.JspTagException)

Example 8 with XPathVariableResolver

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);
    }
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpressionException(javax.xml.xpath.XPathExpressionException) XPathVariableResolver(javax.xml.xpath.XPathVariableResolver) JspTagException(jakarta.servlet.jsp.JspTagException)

Aggregations

XPathVariableResolver (javax.xml.xpath.XPathVariableResolver)8 XPath (javax.xml.xpath.XPath)7 JspTagException (jakarta.servlet.jsp.JspTagException)4 XPathExpressionException (javax.xml.xpath.XPathExpressionException)4 Iterator (java.util.Iterator)3 List (java.util.List)3 NamespaceContext (javax.xml.namespace.NamespaceContext)3 QName (javax.xml.namespace.QName)3 XPathFactory (javax.xml.xpath.XPathFactory)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 XPathFunction (javax.xml.xpath.XPathFunction)2 XPathFunctionResolver (javax.xml.xpath.XPathFunctionResolver)2 Node (org.w3c.dom.Node)2 VCFIterator (htsjdk.variant.vcf.VCFIterator)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 NodeList (org.w3c.dom.NodeList)1 XDContainer (org.xdef.XDContainer)1 XCodeProcessor (org.xdef.impl.XCodeProcessor)1 SIllegalArgumentException (org.xdef.sys.SIllegalArgumentException)1