/** * Create a compiled XPath expression using the given string. * * @param expression the XPath expression * @return the compiled XPath expression * @throws IllegalStateException if neither JAXP 1.3+, or Jaxen are available * @throws XPathParseException if the given expression cannot be parsed */ public static XPathExpression createXPathExpression(String expression) throws IllegalStateException, XPathParseException { return createXPathExpression(expression, Collections.<String, String>emptyMap()); }
/** * Create a compiled XPath expression using the given string and namespaces. The namespace map should consist of * string prefixes mapped to string namespaces. * * @param expression the XPath expression * @param namespaces a map that binds string prefixes to string namespaces * @return the compiled XPath expression * @throws IllegalStateException if neither JAXP 1.3+, or Jaxen are available * @throws XPathParseException if the given expression cannot be parsed */ public static XPathExpression createXPathExpression(String expression, Map<String, String> namespaces) throws IllegalStateException, XPathParseException { Assert.hasLength(expression, "expression is empty"); if (namespaces == null) { namespaces = Collections.emptyMap(); } try { logger.trace("Creating [javax.xml.xpath.XPathExpression]"); return Jaxp13XPathExpressionFactory.createXPathExpression(expression, namespaces); } catch (XPathException e) { throw e; } }
/** * Create a compiled XPath expression using the given string and namespaces. The namespace map should consist of * string prefixes mapped to string namespaces. * * @param expression the XPath expression * @param namespaces a map that binds string prefixes to string namespaces * @return the compiled XPath expression * @throws IllegalStateException if neither JAXP 1.3+, or Jaxen are available * @throws XPathParseException if the given expression cannot be parsed */ public static XPathExpression createXPathExpression(String expression, Map<String, String> namespaces) throws IllegalStateException, XPathParseException { Assert.hasLength(expression, "expression is empty"); if (namespaces == null) { namespaces = Collections.emptyMap(); } try { logger.trace("Creating [javax.xml.xpath.XPathExpression]"); return Jaxp13XPathExpressionFactory.createXPathExpression(expression, namespaces); } catch (XPathException e) { throw e; } }