* @return the compiled {@code XPathExpression}
* @throws XPathParseException when the given expression cannot be parsed
*/
public static XPathExpression createXPathExpression(String expression, Map<String, String> namespaces) {
try {
XPath xpath = new DOMXPath(expression);
xpath.setNamespaceContext(new SimpleNamespaceContext(namespaces));
return new JaxenXpathExpression(xpath);
}
catch (JaxenException ex) {
throw new org.springframework.xml.xpath.XPathParseException(
"Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex);