Class SimpleXpathEngine

  • All Implemented Interfaces:
    XMLConstants, XpathEngine, XSLTConstants

    public class SimpleXpathEngine
    extends java.lang.Object
    implements XpathEngine, 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
    • Constructor Detail

      • SimpleXpathEngine

        public SimpleXpathEngine()
    • Method Detail

      • getXPathResultNode

        protected org.w3c.dom.Node getXPathResultNode​(java.lang.String select,
                                                      org.w3c.dom.Document document)
                                               throws ConfigurationException,
                                                      javax.xml.transform.TransformerException,
                                                      XpathException
        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:
        ConfigurationException
        javax.xml.transform.TransformerException
        XpathException
      • getXPathResultAsDocument

        protected org.w3c.dom.Document getXPathResultAsDocument​(java.lang.String select,
                                                                org.w3c.dom.Document document)
                                                         throws ConfigurationException,
                                                                javax.xml.transform.TransformerException,
                                                                XpathException
        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:
        ConfigurationException
        javax.xml.transform.TransformerException
        XpathException