Class DefaultNodeMatcher

java.lang.Object
org.xmlunit.diff.DefaultNodeMatcher
All Implemented Interfaces:
NodeMatcher

public class DefaultNodeMatcher extends Object implements NodeMatcher
Default implemetation of NodeMatcher that matches control and tests nodes for comparison with the help of DefaultNodeMatcher.NodeTypeMatcher and ElementSelectors.

There is an important difference between using ElementSelectors.or(org.xmlunit.diff.ElementSelector...) to combine multiple ElementSelectors and using DefaultNodeMatcher's constructor with multiple ElementSelectors:

Consider ElementSelectors e1 and e2 and two control and test nodes each. Assume e1 would match the first control node to the second test node and vice versa if used alone, while e2 would match the nodes in order (the first control node to the first test and so on).

ElementSelectors.or(org.xmlunit.diff.ElementSelector...) creates a combined ElementSelector that is willing to match the first control node to both of the test nodes - and the same for the second control node. Since nodes are compared in order when possible the result will be the same as running e2 alone.

DefaultNodeMatcher with two ElementSelectors will consult the ElementSelectors separately and only invoke e2 if there are any nodes not matched by e1 at all. In this case the result will be the same as running e1 alone.