Package org.xmlunit.xpath
Class JAXPXPathEngine
- java.lang.Object
-
- org.xmlunit.xpath.JAXPXPathEngine
-
- All Implemented Interfaces:
XPathEngine
public class JAXPXPathEngine extends Object implements XPathEngine
Simplified access to JAXP's XPath API.
-
-
Constructor Summary
Constructors Constructor Description JAXPXPathEngine()Create an XPathEngine that uses JAXP's default XPathFactory withXPathFactoryConfigurer.Defaultapplied under the covers.JAXPXPathEngine(XPathFactory fac)Create an XPathEngine that uses a custom XPathFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringevaluate(String xPath, Source s)Evaluates an XPath expression and stringifies the result.Stringevaluate(String xPath, Node n)Evaluates an XPath expression and stringifies the result.Iterable<Node>selectNodes(String xPath, Source s)Returns a potentially empty collection of Nodes matching an XPath expression.Iterable<Node>selectNodes(String xPath, Node n)Returns a potentially empty collection of Nodes matching an XPath expression.voidsetNamespaceContext(Map<String,String> prefix2Uri)Establish a namespace context.
-
-
-
Constructor Detail
-
JAXPXPathEngine
public JAXPXPathEngine(XPathFactory fac)
Create an XPathEngine that uses a custom XPathFactory.- Parameters:
fac- the factory to use
-
JAXPXPathEngine
public JAXPXPathEngine()
Create an XPathEngine that uses JAXP's default XPathFactory withXPathFactoryConfigurer.Defaultapplied under the covers.
-
-
Method Detail
-
selectNodes
public Iterable<Node> selectNodes(String xPath, Source s)
Returns a potentially empty collection of Nodes matching an XPath expression.- Specified by:
selectNodesin interfaceXPathEngine- Parameters:
xPath- the XPath expressions- the XML source to apply the expression to- Returns:
- matching nodes
-
evaluate
public String evaluate(String xPath, Source s)
Evaluates an XPath expression and stringifies the result.- Specified by:
evaluatein interfaceXPathEngine- Parameters:
xPath- the XPath expressions- the XML source to apply the expression to- Returns:
- stringified result
-
selectNodes
public Iterable<Node> selectNodes(String xPath, Node n)
Returns a potentially empty collection of Nodes matching an XPath expression.- Specified by:
selectNodesin interfaceXPathEngine- Parameters:
xPath- the XPath expressionn- the XML source to apply the expression to- Returns:
- matching nodes
-
evaluate
public String evaluate(String xPath, Node n)
Evaluates an XPath expression and stringifies the result.- Specified by:
evaluatein interfaceXPathEngine- Parameters:
xPath- the XPath expressionn- the XML source to apply the expression to- Returns:
- stringified result
-
setNamespaceContext
public void setNamespaceContext(Map<String,String> prefix2Uri)
Establish a namespace context.- Specified by:
setNamespaceContextin interfaceXPathEngine- Parameters:
prefix2Uri- maps from prefix to namespace URI.
-
-