Class XPathDifferenceHandler

    • Constructor Detail

      • XPathDifferenceHandler

        public XPathDifferenceHandler​(boolean stripPositions)
        Creates a new XPathDifferenceHandler.

        If there is a difference you want to ignore at the following XPath location

         /datasource/data/selection[2]/option[4]
         
        you can achieve this by either setting up your XPathDifferenceHandler like this
         DifferenceHandler differenceHandler = new XPathDifferenceHandler(true);
         differenceHandler.ignoreDifference("/datasource/data/selection/option");
         
        or this
         DifferenceHandler differenceHandler = new XPathDifferenceHandler(false);
         differenceHandler.ignoreDifference("/datasource/data/selection[2]/option[4]");
         
        In the first case, with stripPositions = true, you can omit the positions from the expression. As a side effect, every Difference with the (stripped) XPath of /datasource/data/selection/option will be ignored.
        In the second case, there needs to be an exact match between the registered XPath location and the one from the Difference.

        Parameters:
        stripPositions - whether or not to strip the positions from the actual XPath of the Difference before checking the registry for an appropriate DifferenceListener
    • Method Detail

      • ignoreDifference

        public void ignoreDifference​(String xpath)
        Ignore the Difference with the given XPath expression
        Parameters:
        xpath - the XPath expression. Note that this must be the complete absolute XPath location starting from the document root.
      • addDifferenceListener

        public void addDifferenceListener​(String xpath,
                                          DifferenceListener differenceListener)
        Registers a custom DifferenceListener for the given XPath expression
        Parameters:
        xpath - the XPath expression. Note that this must be the complete absolute XPath location starting from the document root.
        differenceListener - the DifferenceListener to register