From: <slo...@gm...> - 2008-03-11 11:08:01
|
Hi there, I am pretty new to XMLUnit. My intent is to write a small XML diff tool for a set of XML files that I have. XMLUnit 1.1 appears to be a good starting point for this. I tried to start small and therefore was filtering differences of nodes of type "c0" only. My "qualifyForComparison()" implementation is this: ------------------------------------------------------------------------- public boolean qualifyForComparison(Element control, Element test) { boolean result = false; if (control != null && test != null) { if (control.getNodeType() == Node.COMMENT_NODE || test.getNodeType() == Node.COMMENT_NODE) { result = false; } else if (control.getTagName().equals(test.getTagName())) { String controlID = control.getAttribute("id"); if (controlID != null) { result = controlID.equals(test.getAttribute("id")); } else { // element without "id" result = true; } } } return result; } ------------------------------------------------------------------------- My assumption is that this code does not allow comparison of an element node and a comment node, because I explicitly filter comment nodes. However, in the output of my tool I see this: ------------------------------------------------------------------------- Difference found: Expected node type '1' but was '8' - comparing <c0...> at /a0[1]/b0[1]/c0[2] to <!-- some comment --> at /a0[1]/b0[1]/comment()[1] ------------------------------------------------------------------------- Is this correct? If it is, could some explain, how I could prevent the comparison of element nodes and comment nodes, please? I tried to attach the sources of my proof of concept, the input XML scripts as well as the output. But the mailer daemon did not allow attachements. Please, let me know, how I can provide that information, if it is useful for investigation. Kind regards and thanks in advance, slowjoe -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer |