Package org.xmlunit.diff
Interface DifferenceEngine
- All Known Implementing Classes:
AbstractDifferenceEngine
,DOMDifferenceEngine
public interface DifferenceEngine
XMLUnit's difference engine.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Registers a listener that is notified of each comparison.void
Registers a listener that is notified of each comparison with outcome other thanComparisonResult.EQUAL
.void
Registers a listener that is notified of each comparison with outcomeComparisonResult.EQUAL
.void
Compares two pieces of XML and invokes the registered listeners.void
setAttributeFilter
(Predicate<Attr> attributeFilter) Sets the optional strategy that decides which attributes to consider and which to ignore during comparison.void
Determines whether the comparison should stop after given difference has been found.void
Evaluates the severity of a difference.void
setNamespaceContext
(Map<String, String> prefix2Uri) Establish a namespace context that will be used inComparison.Detail#getXPath
.void
setNodeFilter
(Predicate<Node> nodeFilter) Sets the optional strategy that decides which nodes to consider and which to ignore during comparison.void
Sets the strategy for selecting nodes to compare.
-
Method Details
-
addComparisonListener
Registers a listener that is notified of each comparison.- Parameters:
l
- the listener to add
-
addMatchListener
Registers a listener that is notified of each comparison with outcomeComparisonResult.EQUAL
.- Parameters:
l
- the listener to add
-
addDifferenceListener
Registers a listener that is notified of each comparison with outcome other thanComparisonResult.EQUAL
.- Parameters:
l
- the listener to add
-
setNodeMatcher
Sets the strategy for selecting nodes to compare.- Parameters:
n
- the strategy to use
-
setAttributeFilter
Sets the optional strategy that decides which attributes to consider and which to ignore during comparison.Only attributes for which the predicate returns true are part of the comparison. By default all attributes are considered.
The "special" namespace, namespace-location and schema-instance-type attributes can not be ignored this way. If you want to suppress comparison of them you'll need to implement
DifferenceEvaluator
.- Parameters:
attributeFilter
- the strategy to use
-
setNodeFilter
Sets the optional strategy that decides which nodes to consider and which to ignore during comparison.Only nodes for which the predicate returns true are part of the comparison. By default nodes that are not document types are considered.
- Parameters:
nodeFilter
- the strategy to use
-
setDifferenceEvaluator
Evaluates the severity of a difference.- Parameters:
e
- the evaluator to use
-
setComparisonController
Determines whether the comparison should stop after given difference has been found.- Parameters:
c
- the controller to use
-
setNamespaceContext
Establish a namespace context that will be used inComparison.Detail#getXPath
.Without a namespace context (or with an empty context) the XPath expressions will only use local names for elements and attributes.
- Parameters:
prefix2Uri
- maps from prefix to namespace URI.
-
compare
Compares two pieces of XML and invokes the registered listeners.- Parameters:
control
- the reference source of "good" XMLtest
- the source under test to compare againstcontrol
-