public class DefaultNodeMatcher extends Object implements NodeMatcher
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultNodeMatcher.DefaultNodeTypeMatcher
DefaultNodeMatcher.NodeTypeMatcher that marks pairs of nodes of the same
node type as well as pairs of CDATA sections and text nodes as
eligible. |
static interface |
DefaultNodeMatcher.NodeTypeMatcher
Determines whether two Nodes are eligible for comparison based
on their node type.
|
| Constructor and Description |
|---|
DefaultNodeMatcher()
Creates a matcher using
ElementSelectors.Default and
DefaultNodeMatcher.DefaultNodeTypeMatcher. |
DefaultNodeMatcher(DefaultNodeMatcher.NodeTypeMatcher ntm,
ElementSelector... es)
Creates a matcher using the given
ElementSelectors and
DefaultNodeMatcher.NodeTypeMatcher. |
DefaultNodeMatcher(ElementSelector... es)
Creates a matcher using the given
ElementSelectors and
DefaultNodeMatcher.DefaultNodeTypeMatcher. |
public DefaultNodeMatcher()
ElementSelectors.Default and
DefaultNodeMatcher.DefaultNodeTypeMatcher.public DefaultNodeMatcher(ElementSelector... es)
ElementSelectors and
DefaultNodeMatcher.DefaultNodeTypeMatcher.es - the ElementSelectors to usepublic DefaultNodeMatcher(DefaultNodeMatcher.NodeTypeMatcher ntm, ElementSelector... es)
ElementSelectors and
DefaultNodeMatcher.NodeTypeMatcher.
The ElementSelectors are consulted in order so that
the second ElementSelector only gets to match the nodes
that the first one couldn't match to any test nodes ate all and
so on.
ntm - the NodeTypeMatcher to usees - the ElementSelectors to usepublic Iterable<Map.Entry<Node,Node>> match(Iterable<Node> controlNodes, Iterable<Node> testNodes)
NodeMatcherNodes passed in as attributes but not returned as member of
any pair will cause ComparisonType.CHILD_LOOKUP
differences}.
match in interface NodeMatchercontrolNodes - the control nodestestNodes - the test nodesCopyright © 2001–2025 XMLUnit. All rights reserved.