Search in sources :

Example 1 with SimpleNamespaceContext

use of org.springframework.util.xml.SimpleNamespaceContext in project spring-framework by spring-projects.

the class XpathExpectationsHelper method compileXpathExpression.

private XPathExpression compileXpathExpression(String expression, Map<String, String> namespaces) throws XPathExpressionException {
    SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
    namespaceContext.setBindings((namespaces != null) ? namespaces : Collections.<String, String>emptyMap());
    XPath xpath = XPathFactory.newInstance().newXPath();
    xpath.setNamespaceContext(namespaceContext);
    return xpath.compile(expression);
}
Also used : XPath(javax.xml.xpath.XPath) SimpleNamespaceContext(org.springframework.util.xml.SimpleNamespaceContext)

Aggregations

XPath (javax.xml.xpath.XPath)1 SimpleNamespaceContext (org.springframework.util.xml.SimpleNamespaceContext)1