From: Stefan B. <bo...@ap...> - 2008-03-11 12:16:13
|
Hi, On Tue, 11 Mar 2008, slowjoe <slo...@gm...> wrote: > I tried to start small and therefore was filtering differences of > nodes of type "c0" only. > > My "qualifyForComparison()" implementation is this: qualifyForComparision as in "I implemented ElementQualifier", right? ElementQualifier is not the right place for filtering. Let me first explain what ElementQualifier does and then try to find a better place for you to hook in. Let's say XMLUnit finds a collection of child elements of a given XML element, then ElementQualifier will tell it which of the child elements of the control document should be compared to which child element of the test document. It's job is to say "yes, this control element can be compared to this test element", it cannot say "skip this element", it doesn't say anything about the element's equality and it will never be invoked for anything but DOM Elements. OK. So where do you hook in? I'd say DifferenceListener is what you want. Implement DifferenceListener and tell XMLUnit to ignore all Differences that are related to parts that you are currently not interested in. Looking at you code > String controlID = control.getAttribute("id"); > if (controlID != null) > { > result = controlID.equals(test.getAttribute("id")); > } You will probably still need an ElementQualifier so that you can tell XMLUnit to match your "c0" elements based on their id-Attribute values. ElementNameAndAttributeQualifier may or may not work in your case (depends on the other attributes). Cheers Stefan |