Package org.xmlunit.diff
Class DOMDifferenceEngine
java.lang.Object
org.xmlunit.diff.AbstractDifferenceEngine
org.xmlunit.diff.DOMDifferenceEngine
- All Implemented Interfaces:
DifferenceEngine
Difference engine based on DOM.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private class
private class
private class
private class
Nested classes/interfaces inherited from class org.xmlunit.diff.AbstractDifferenceEngine
AbstractDifferenceEngine.ComparisonState, AbstractDifferenceEngine.DeferredComparison, AbstractDifferenceEngine.FinishedComparisonState, AbstractDifferenceEngine.OngoingComparisonState
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DOMDifferenceEngine using the defaultDocumentBuilderFactory
.Creates a new DOMDifferenceEngine. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Compares two pieces of XML and invokes the registered listeners.compareAttributeExplicitness
(Attr control, XPathContext controlContext, Attr test, XPathContext testContext) Compares whether two attributes are specified explicitly.compareAttributes
(Attr control, XPathContext controlContext, Attr test, XPathContext testContext) Compares properties of an attribute.compareCharacterData
(CharacterData control, XPathContext controlContext, CharacterData test, XPathContext testContext) Compares textual content.compareChildren
(XPathContext controlContext, Iterable<Node> allControlChildren, Iterable<Node> controlChildren, XPathContext testContext, Iterable<Node> allTestChildren, Iterable<Node> testChildren) compareDeclarations
(Document control, XPathContext controlContext, Document test, XPathContext testContext) Compares properties of XML declaration.compareDocTypes
(DocumentType control, XPathContext controlContext, DocumentType test, XPathContext testContext) Compares properties of the doctype declaration.compareDocuments
(Document control, XPathContext controlContext, Document test, XPathContext testContext) Compares document node, doctype and XML declaration propertiescompareElementAttributes
(Element control, XPathContext controlContext, Element test, XPathContext testContext) Compares element's attributes.compareElements
(Element control, XPathContext controlContext, Element test, XPathContext testContext) Compares elements node properties, in particular the element's name and its attributes.compareNodeLists
(Iterable<Node> allControlChildren, Iterable<Node> controlSeq, XPathContext controlContext, Iterable<Node> allTestChildren, Iterable<Node> testSeq, XPathContext testContext) Matches nodes of two node lists and invokes compareNode on each pair.(package private) AbstractDifferenceEngine.ComparisonState
compareNodes
(Node control, XPathContext controlContext, Node test, XPathContext testContext) Recursively compares two XML nodes.compareProcessingInstructions
(ProcessingInstruction control, XPathContext controlContext, ProcessingInstruction test, XPathContext testContext) Compares properties of a processing instruction.compareXsiType
(Attr controlAttr, XPathContext controlContext, Attr testAttr, XPathContext testContext) Compares xsi:type attribute valuesprivate <T extends Node>
TfilterNode
(T n) private static Attr
findMatchingAttr
(List<Attr> attrs, Attr attrToMatch) Find the attribute with the same namespace and local name as a given attribute in a list of attributes.nodeTypeSpecificComparison
(Node control, XPathContext controlContext, Node test, XPathContext testContext) Dispatches to the node type specific comparison if one is defined for the given combination of nodes.void
Deprecated.use the one-arg constructor insteadprivate DOMDifferenceEngine.Attributes
Separates XML namespace related attributes from "normal" attributes.xbprivate static QName
valueAsQName
(Attr attribute) private XPathContext
Methods inherited from class org.xmlunit.diff.AbstractDifferenceEngine
addComparisonListener, addDifferenceListener, addMatchListener, compare, getAttributeFilter, getComparisonController, getDifferenceEvaluator, getNamespaceContext, getNodeFilter, getNodeMatcher, getParentXPath, getXPath, setAttributeFilter, setComparisonController, setDifferenceEvaluator, setNamespaceContext, setNodeFilter, setNodeMatcher
-
Field Details
-
QNAME_MAPPER
Maps Nodes to their QNames. -
documentBuilderFactory
-
-
Constructor Details
-
DOMDifferenceEngine
public DOMDifferenceEngine()Creates a new DOMDifferenceEngine using the defaultDocumentBuilderFactory
. -
DOMDifferenceEngine
Creates a new DOMDifferenceEngine.The
DocumentBuilderFactory
is only used if theSource
passed tocompare(javax.xml.transform.Source, javax.xml.transform.Source)
is not already aDOMSource
.
-
-
Method Details
-
setDocumentBuilderFactory
Deprecated.use the one-arg constructor insteadSets theDocumentBuilderFactory
to use when creating aDocument
from theSource
s to compare.This is only used if the
Source
passed tocompare(javax.xml.transform.Source, javax.xml.transform.Source)
is not already aDOMSource
. -
compare
Description copied from interface:DifferenceEngine
Compares two pieces of XML and invokes the registered listeners. -
xpathContextFor
-
compareNodes
AbstractDifferenceEngine.ComparisonState compareNodes(Node control, XPathContext controlContext, Node test, XPathContext testContext) Recursively compares two XML nodes.Performs comparisons common to all node types, then performs the node type specific comparisons and finally recurses into the node's child lists.
Stops as soon as any comparison returns ComparisonResult.CRITICAL.
package private to support tests.
-
nodeTypeSpecificComparison
private AbstractDifferenceEngine.ComparisonState nodeTypeSpecificComparison(Node control, XPathContext controlContext, Node test, XPathContext testContext) Dispatches to the node type specific comparison if one is defined for the given combination of nodes. -
compareChildren
private AbstractDifferenceEngine.DeferredComparison compareChildren(XPathContext controlContext, Iterable<Node> allControlChildren, Iterable<Node> controlChildren, XPathContext testContext, Iterable<Node> allTestChildren, Iterable<Node> testChildren) -
compareCharacterData
private AbstractDifferenceEngine.ComparisonState compareCharacterData(CharacterData control, XPathContext controlContext, CharacterData test, XPathContext testContext) Compares textual content. -
compareDocuments
private AbstractDifferenceEngine.ComparisonState compareDocuments(Document control, XPathContext controlContext, Document test, XPathContext testContext) Compares document node, doctype and XML declaration properties -
filterNode
-
compareDocTypes
private AbstractDifferenceEngine.ComparisonState compareDocTypes(DocumentType control, XPathContext controlContext, DocumentType test, XPathContext testContext) Compares properties of the doctype declaration. -
compareDeclarations
private AbstractDifferenceEngine.DeferredComparison compareDeclarations(Document control, XPathContext controlContext, Document test, XPathContext testContext) Compares properties of XML declaration. -
compareElements
private AbstractDifferenceEngine.ComparisonState compareElements(Element control, XPathContext controlContext, Element test, XPathContext testContext) Compares elements node properties, in particular the element's name and its attributes. -
compareElementAttributes
private AbstractDifferenceEngine.ComparisonState compareElementAttributes(Element control, XPathContext controlContext, Element test, XPathContext testContext) Compares element's attributes. -
compareProcessingInstructions
private AbstractDifferenceEngine.ComparisonState compareProcessingInstructions(ProcessingInstruction control, XPathContext controlContext, ProcessingInstruction test, XPathContext testContext) Compares properties of a processing instruction. -
compareNodeLists
private AbstractDifferenceEngine.ComparisonState compareNodeLists(Iterable<Node> allControlChildren, Iterable<Node> controlSeq, XPathContext controlContext, Iterable<Node> allTestChildren, Iterable<Node> testSeq, XPathContext testContext) Matches nodes of two node lists and invokes compareNode on each pair.Also performs CHILD_LOOKUP comparisons for each node that couldn't be matched to one of the "other" list.
-
compareXsiType
private AbstractDifferenceEngine.ComparisonState compareXsiType(Attr controlAttr, XPathContext controlContext, Attr testAttr, XPathContext testContext) Compares xsi:type attribute values -
compareAttributes
private AbstractDifferenceEngine.ComparisonState compareAttributes(Attr control, XPathContext controlContext, Attr test, XPathContext testContext) Compares properties of an attribute. -
compareAttributeExplicitness
private AbstractDifferenceEngine.DeferredComparison compareAttributeExplicitness(Attr control, XPathContext controlContext, Attr test, XPathContext testContext) Compares whether two attributes are specified explicitly. -
splitAttributes
Separates XML namespace related attributes from "normal" attributes.xb -
valueAsQName
-
findMatchingAttr
Find the attribute with the same namespace and local name as a given attribute in a list of attributes. -
index
-