org.custommonkey.xmlunit

Class SimpleXpathEngine

public class SimpleXpathEngine extends Object implements XSLTConstants

Simple class for accessing the Nodes matched by an Xpath expression, or evaluating the String value of an Xpath expression. Uses a copy-of or value-of XSL template (as appropriate) to execute the Xpath. This is not an efficient method for accessing XPaths but it is portable across underlying transform implementations. (Yes I know Jaxen is too, but this approach seemed to be the simplest thing that could possibly work...)
Examples and more at xmlunit.sourceforge.net
Method Summary
Stringevaluate(String select, Document document)
Evaluate the result of executing the specified xpath syntax select expression on the specified document
NodeListgetMatchingNodes(String select, Document document)
Execute the specified xpath syntax select expression on the specified document and return the list of nodes (could have length zero) that match
protected DocumentgetXPathResultAsDocument(String select, Document document)
Execute the copy-of transform and return the resulting Document.
protected NodegetXPathResultNode(String select, Document document)
Testable method to execute the copy-of transform and return the root node of the resulting Document.

Method Detail

evaluate

public String evaluate(String select, Document document)
Evaluate the result of executing the specified xpath syntax select expression on the specified document

Parameters: select document

Returns: evaluated result

Throws: TransformerException TransformerConfigurationException

getMatchingNodes

public NodeList getMatchingNodes(String select, Document document)
Execute the specified xpath syntax select expression on the specified document and return the list of nodes (could have length zero) that match

Parameters: select document

Returns: list of matching nodes

Throws: TransformerException TransformerConfigurationException

getXPathResultAsDocument

protected Document getXPathResultAsDocument(String select, Document document)
Execute the copy-of transform and return the resulting Document. Used for XMLTestCase comparison

Parameters: select document

Returns: the Document created by the copy-of transform.

Throws: TransformerException

getXPathResultNode

protected Node getXPathResultNode(String select, Document document)
Testable method to execute the copy-of transform and return the root node of the resulting Document.

Parameters: select document

Returns: the root node of the Document created by the copy-of transform.

Throws: TransformerException