Search in sources :

Example 1 with NodeSet

use of com.sun.org.apache.xpath.internal.NodeSet in project Payara by payara.

the class VerifierTest method getNonRuntimeCountNodeSet.

public int getNonRuntimeCountNodeSet(String xpath) {
    try {
        // int value = -1;
        Document d = getVerifierContext().getDocument();
        if (d == null)
            return -1;
        XObject result = XPathAPI.eval(d, xpath, (PrefixResolver) new XpathPrefixResolver(d));
        NodeList nl = result.nodelist();
        NodeSet ns = new NodeSet(nl);
        return ns.getLength();
    } catch (Exception ex) {
        ex.printStackTrace();
        return -1;
    }
}
Also used : NodeSet(com.sun.org.apache.xpath.internal.NodeSet) XpathPrefixResolver(com.sun.enterprise.tools.verifier.XpathPrefixResolver) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) XObject(com.sun.org.apache.xpath.internal.objects.XObject)

Example 2 with NodeSet

use of com.sun.org.apache.xpath.internal.NodeSet in project Payara by payara.

the class VerifierTest method getCountNodeSet.

/*
     * getCountNodeSet( String xpath)
     *   return the number of nodes for the specified xpath
     */
public int getCountNodeSet(String xpath) {
    try {
        // int value = -1;
        Document d = getVerifierContext().getRuntimeDocument();
        if (d == null)
            return -1;
        NodeSet ns = new NodeSet(XPathAPI.selectNodeList(d, xpath));
        return ns.getLength();
    } catch (Exception ex) {
        ex.printStackTrace();
        return -1;
    }
}
Also used : NodeSet(com.sun.org.apache.xpath.internal.NodeSet) Document(org.w3c.dom.Document)

Aggregations

NodeSet (com.sun.org.apache.xpath.internal.NodeSet)2 Document (org.w3c.dom.Document)2 XpathPrefixResolver (com.sun.enterprise.tools.verifier.XpathPrefixResolver)1 XObject (com.sun.org.apache.xpath.internal.objects.XObject)1 NodeList (org.w3c.dom.NodeList)1