|
From: Stefan B. <bo...@ap...> - 2010-10-01 03:54:10
|
On 2010-09-28, Miguel wrote: > I have a doubt though: I'm trying to compare 2 XML files for their > content. This means that: > <primarysource> > <reportertitle>Dr</reportertitle> > <reportergivename>Antonio</reportergivename> > <reportermiddlename></reportermiddlename> > <reporterfamilyname>Perez</reporterfamilyname> > <primarysource> > and > <primarysource> > <reportertitle>Dr</reportertitle> > <reportergivename>Antonio</reportergivename> > <reporterfamilyname>Perez</reporterfamilyname> > <primarysource> > Are similar, because the non-null/empty content is essentially the same. > Is there an option on xmlunit to make the Diff engine ignore empty tags > so that these XML are calculated to be similar? No, no built-in option. You could write an implementation of DifferenceListener <http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#DifferenceListener> which would check whether the Node that is part of a CHILD_NODE_NOT difference has an empty text content and return RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR in that case. You will also want to disable compareUnmateched <http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#Comparison%20of%20Unmatched%20Elements> Stefan |