use of org.custommonkey.xmlunit.XpathEngine in project camel by apache.
the class Utils method evaluate.
/**
* Evaluate an XPATH expression.
*
* @param xpath
* @param xml
* @return
*/
public static String evaluate(final String xpath, final String xml) {
Map<String, Object> m = new HashMap<String, Object>();
m.put("svrl", Constants.HTTP_PURL_OCLC_ORG_DSDL_SVRL);
XpathEngine xpathEngine = XMLUnit.newXpathEngine();
xpathEngine.setNamespaceContext(new SimpleNamespaceContext(m));
try {
return xpathEngine.evaluate(xpath, XMLUnit.buildControlDocument(xml));
} catch (Exception e) {
LOG.error("Failed to apply xpath {} on xml {}", xpath, xml);
throw new RuntimeCamelException(e);
}
}
Aggregations