use of com.sun.enterprise.tools.verifier.XpathPrefixResolver in project Payara by payara.
the class VerifierTest method getXPathValueForNonRuntime.
/*
*getXPathValueForNonRuntime(String xpath)
* return String - is the value of the element specified in the xpath.
*/
public String getXPathValueForNonRuntime(String xpath) {
try {
String value = null;
Document d = getVerifierContext().getDocument();
if (d == null)
return null;
XObject result = XPathAPI.eval(d, xpath, (PrefixResolver) new XpathPrefixResolver(d));
NodeList nl = result.nodelist();
for (int i = 0; i < nl.getLength(); i++) {
Node n = ((Node) nl.item(i)).getFirstChild();
if (n == null)
return null;
value = n.getNodeValue();
}
return value;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
use of com.sun.enterprise.tools.verifier.XpathPrefixResolver 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;
}
}