/** * 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()); }
/** * Creates a JAXP 1.3 {@code XPathExpression} from the given string expression. * * @param expression the XPath expression * @return the compiled {@code XPathExpression} * @throws XPathParseException when the given expression cannot be parsed */ static XPathExpression createXPathExpression(String expression) { try { XPath xpath = createXPath(); javax.xml.xpath.XPathExpression xpathExpression = xpath.compile(expression); return new Jaxp13XPathExpression(xpathExpression, expression); } catch (XPathExpressionException ex) { throw new org.springframework.xml.xpath.XPathParseException( "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex); } }
/** * Creates a JAXP 1.3 {@code XPathExpression} from the given string expression. * * @param expression the XPath expression * @return the compiled {@code XPathExpression} * @throws XPathParseException when the given expression cannot be parsed */ static XPathExpression createXPathExpression(String expression) { try { XPath xpath = createXPath(); javax.xml.xpath.XPathExpression xpathExpression = xpath.compile(expression); return new Jaxp13XPathExpression(xpathExpression, expression); } catch (XPathExpressionException ex) { throw new org.springframework.xml.xpath.XPathParseException( "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex); } }
/** * 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; } }
/** * Creates a JAXP 1.3 {@code XPathExpression} from the given string expression and namespaces. * * @param expression the XPath expression * @param namespaces the namespaces * @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 = createXPath(); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(); namespaceContext.setBindings(namespaces); xpath.setNamespaceContext(namespaceContext); javax.xml.xpath.XPathExpression xpathExpression = xpath.compile(expression); return new Jaxp13XPathExpression(xpathExpression, expression); } catch (XPathExpressionException ex) { throw new org.springframework.xml.xpath.XPathParseException( "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex); } }
/** * 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; } }
/** * Creates a JAXP 1.3 {@code XPathExpression} from the given string expression and namespaces. * * @param expression the XPath expression * @param namespaces the namespaces * @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 = createXPath(); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(); namespaceContext.setBindings(namespaces); xpath.setNamespaceContext(namespaceContext); javax.xml.xpath.XPathExpression xpathExpression = xpath.compile(expression); return new Jaxp13XPathExpression(xpathExpression, expression); } catch (XPathExpressionException ex) { throw new org.springframework.xml.xpath.XPathParseException( "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex); } }