Class DOMDifferenceEngine

    • Field Detail

      • QNAME_MAPPER

        private static final Mapper<org.w3c.dom.Node,​javax.xml.namespace.QName> QNAME_MAPPER
        Maps Nodes to their QNames.
      • documentBuilderFactory

        private javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory
    • Constructor Detail

      • DOMDifferenceEngine

        public DOMDifferenceEngine()
    • Method Detail

      • setDocumentBuilderFactory

        public void setDocumentBuilderFactory​(javax.xml.parsers.DocumentBuilderFactory f)
        Sets the DocumentBuilderFactory to use when creating a Document from the Sources to compare.

        This is only used if the Source passed to compare(javax.xml.transform.Source, javax.xml.transform.Source) is not already a DOMSource.

        Since:
        XMLUnit 2.2.0
      • compare

        public void compare​(javax.xml.transform.Source control,
                            javax.xml.transform.Source test)
        Description copied from interface: DifferenceEngine
        Compares two pieces of XML and invokes the registered listeners.
      • xpathContextFor

        private XPathContext xpathContextFor​(org.w3c.dom.Node n)
      • compareNodes

        AbstractDifferenceEngine.ComparisonState compareNodes​(org.w3c.dom.Node control,
                                                              XPathContext controlContext,
                                                              org.w3c.dom.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.

      • compareChildren

        private AbstractDifferenceEngine.DeferredComparison compareChildren​(XPathContext controlContext,
                                                                            java.lang.Iterable<org.w3c.dom.Node> allControlChildren,
                                                                            java.lang.Iterable<org.w3c.dom.Node> controlChildren,
                                                                            XPathContext testContext,
                                                                            java.lang.Iterable<org.w3c.dom.Node> allTestChildren,
                                                                            java.lang.Iterable<org.w3c.dom.Node> testChildren)
      • filterNode

        private <T extends org.w3c.dom.Node> T filterNode​(T n)
      • compareNodeLists

        private AbstractDifferenceEngine.ComparisonState compareNodeLists​(java.lang.Iterable<org.w3c.dom.Node> allControlChildren,
                                                                          java.lang.Iterable<org.w3c.dom.Node> controlSeq,
                                                                          XPathContext controlContext,
                                                                          java.lang.Iterable<org.w3c.dom.Node> allTestChildren,
                                                                          java.lang.Iterable<org.w3c.dom.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.

      • splitAttributes

        private DOMDifferenceEngine.Attributes splitAttributes​(org.w3c.dom.NamedNodeMap map)
        Separates XML namespace related attributes from "normal" attributes.xb
      • valueAsQName

        private static javax.xml.namespace.QName valueAsQName​(org.w3c.dom.Attr attribute)
      • findMatchingAttr

        private static org.w3c.dom.Attr findMatchingAttr​(java.util.List<org.w3c.dom.Attr> attrs,
                                                         org.w3c.dom.Attr attrToMatch)
        Find the attribute with the same namespace and local name as a given attribute in a list of attributes.