Package org.springframework.xml.xpath
Class XPathExpressionFactory
java.lang.Object
org.springframework.xml.xpath.XPathExpressionFactory
Factory for compiled
XPathExpression
s, being aware of JAXP 1.3+ XPath functionality, and Jaxen. Mainly for
internal use of the framework.
The goal of this class is to avoid runtime dependencies a specific XPath engine, simply using the best XPath implementation that is available. Prefers JAXP 1.3+ XPath implementations to Jaxen.
- Since:
- 1.0.0
- Author:
- Arjen Poutsma
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic XPathExpression
createXPathExpression
(String expression) Create a compiled XPath expression using the given string.static XPathExpression
createXPathExpression
(String expression, Map<String, String> namespaces) Create a compiled XPath expression using the given string and namespaces.
-
Constructor Details
-
XPathExpressionFactory
public XPathExpressionFactory()
-
-
Method Details
-
createXPathExpression
public static XPathExpression createXPathExpression(String expression) throws IllegalStateException, XPathParseException Create a compiled XPath expression using the given string.- Parameters:
expression
- the XPath expression- Returns:
- the compiled XPath expression
- Throws:
IllegalStateException
- if neither JAXP 1.3+, or Jaxen are availableXPathParseException
- if the given expression cannot be parsed
-
createXPathExpression
public static XPathExpression createXPathExpression(String expression, Map<String, String> namespaces) throws IllegalStateException, XPathParseExceptionCreate a compiled XPath expression using the given string and namespaces. The namespace map should consist of string prefixes mapped to string namespaces.- Parameters:
expression
- the XPath expressionnamespaces
- a map that binds string prefixes to string namespaces- Returns:
- the compiled XPath expression
- Throws:
IllegalStateException
- if neither JAXP 1.3+, or Jaxen are availableXPathParseException
- if the given expression cannot be parsed
-