I am using XMLUnit to perform a diff on the following two XML strings:
As expected, the differences have "deletions" for the "name" elements in the control, and "insert" for the "names" element in the test string.
However, I am getting a "delete" for the control date element, and "insert" for the test date element,
instead of a text change ( difference id = 14).
I have tried MultiLevelElementNameAndTextQualifier() with level set to 1 and 2, and also ElementNameAndTextQualifier(),
and results are always the same.
Is there a solution?
If I used ElementNameQualifier, then the diff does return a text change for the "date" element.
However, the documents I am working with have multiple levels of XML elements, and need to be compared on name and text because of multiple siblings with the same element name. For example, in the case
The diff compares "C" and "B", instead of declaring "B" as inserted.
So in one case you want XMLUnit to use nested text to identify matching elements and in a different case within the same document you don't. This isn't anything any of the built-in ElementQualifiers can do, they are too generic for your usecase.
The only option you have is to use your own implementation of ElementQualifier which might look ate the element name and the decide whether it needs to consult the nested text (if the local name is para) or not - if it has to, it could delegate to a ElementNameQualifier instance, otherwise it would only match the local names or whatever logic is appropriate in your case.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.