From: SourceForge.net <no...@so...> - 2009-08-12 18:28:00
|
Bugs item #2836385, was opened at 2009-08-12 11:27 Message generated for change (Tracker Item Submitted) made by skolluri You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2836385&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.2 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Sreekanth Kolluri (skolluri) Assigned to: Nobody/Anonymous (nobody) Summary: Similar XML comparison fails Initial Comment: Hi, I'm comparing 2 XML strings that are not identical but similar - both XML strings have the same nodes but in a different order. I used RecursiveElementNameAndTextQualifier but the similar comparison fails. I'm using version 1.2. Here is my java code. import org.custommonkey.xmlunit.XMLUnit; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; public class XMLUnitTest { public static void main(String... args) throws Exception { String s1 = "<main>" + " <inner>" + " <bar>50015</bar>" + " </inner>" + " <inner>" + " <bar>50003</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50020</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + "</main>"; String s2 = "<main>" + " <inner>" + " <bar>50003</bar>" + " </inner>" + " <inner>" + " <bar>50015</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50020</bar>" + " </inner>" + "</main>"; XMLUnit.setIgnoreWhitespace(true); Diff diff = new Diff(s1, s2); diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); boolean isSimilar = diff.similar(); if (!isSimilar) { System.out.println(diff); } } } I get the following error: org.custommonkey.xmlunit.Diff [not identical] Expected sequence of child nodes '0' but was '1' - comparing <inner...> at /main[1]/inner[1] to <inner...> at /main[1]/inner[2] [not identical] Expected sequence of child nodes '1' but was '0' - comparing <inner...> at /main[1]/inner[2] to <inner...> at /main[1]/inner[1] [not identical] Expected sequence of child nodes '3' but was '4' - comparing <inner...> at /main[1]/inner[4] to <inner...> at /main[1]/inner[5] [not identical] Expected sequence of child nodes '4' but was '2' - comparing <inner...> at /main[1]/inner[5] to <inner...> at /main[1]/inner[3] [different] Expected presence of child node 'null' but was 'inner' - comparing at null to <inner...> at /main[1]/inner[4] Thanks for looking into this. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2836385&group_id=23187 |