0

I am comparing my XML files using the sample code (Possible duplicate) in the below post by acdcjunior - Best way to compare 2 XML documents in Java

I see the below error from the assert test.

Expected presence of doctype declaration 'null' but was 'not null' - comparing  at  to <!DOCTYPE plist PSECTOR " ..........

Can someone please guide me what I can do to fix this?

Community
  • 1
  • 1
rickygrimes
  • 2,637
  • 9
  • 46
  • 69

1 Answers1

0

Okay, I found the solution here - http://xmlunit.sourceforge.net/userguide/XMLUnit-Java.pdf

For efficiency reasons a Diff stops the comparison process as soon as the first difference is found. To get all the differences between two pieces of XML an instance of the DetailedDiff class, a subclass of Diff, is required. Note that a Detailed Diff is constructed using an existing Diff instance.

For future readers, here is the solution (also in the link - Pg 9) -

DifferenceListener myDifferenceListener = new IgnoreTextAndAttributeValuesDifferenceListener();
    Diff myDiff = new Diff(expectedXML, actualXML);
    myDiff.overrideDifferenceListener(myDifferenceListener);
    Assert.assertTrue("test XML matches control skeleton XML", myDiff.similar());

From the link again,

    The DifferenceEngine class generates the events that are passed to a DifferenceListener implementation as two
pieces of XML are compared. Using recursion it navigates through the nodes in the control XML DOM, and determines which
node in the test XML DOM qualifies for comparison to the current control node. The qualifying test node will match the control
node’s node type, as well as the node name and namespace (if defined for the control node).
rickygrimes
  • 2,637
  • 9
  • 46
  • 69