Hi All,

I'm working on a project that involves producing visual diffs of XML files. A 
major requirement is that elements should be able to be re-ordered but will not 
display as different unless they are logically different. I thought that 
XMLUnit's Diff class would accomplish this using the similar() function, and 
built my application accordingly. However, when I tested this, I found that 
reordered elements were instead being identified as non-recoverable TEXT_VALUE 
differences.

For example, I have two blocks of XML:
<application-variable>
  <name>database</name>
  <protected>false</protected>
  <value>SupportTracker</value>
</application-variable>
<application-variable>
  <name>conserver</name>
  <protected>false</protected>
  <value>jonathanf-vm</value>
</application-variable>

and 

<application-variable>
  <name>conserver</name>
  <protected>false</protected>
  <value>jonathanf-vm</value>
</application-variable>
<application-variable>
  <name>database</name>
  <protected>false</protected>
  <value>SupportTracker</value>
</application-variable>

These are logically equivalent (similar). However, when I compare these, I get:
Expected text value 'conserver' but was 'database' - comparing conserver at 
/concerto[1]/application[1]/application-variable[1]/name[1]/text()[1] to 
database at 
/concerto[1]/application[1]/application-variable[1]/name[1]/text()[1] 
    
Expected text value 'jonathanf-vm' but was 'SupportTracker' - comparing 
jonathanf-vm at 
/concerto[1]/application[1]/application-variable[1]/value[1]/text()[1] to 
SupportTracker at 
/concerto[1]/application[1]/application-variable[1]/value[1]/text()[1] 

Expected text value 'database' but was 'conserver' - comparing database at 
/concerto[1]/application[1]/application-variable[2]/name[1]/text()[1] to 
conserver at 
/concerto[1]/application[1]/application-variable[2]/name[1]/text()[1] 

Expected text value 'SupportTracker' but was 'jonathanf-vm' - comparing 
SupportTracker at 
/concerto[1]/application[1]/application-variable[2]/value[1]/text()[1] to 
jonathanf-vm at 
/concerto[1]/application[1]/application-variable[2]/value[1]/text()[1]

Is there a way of comparing XML files such that these logical similarities are 
preserved? Am I just not setting a configuration option? Any advice would be 
much appreciated.

Yours Sincerely,
Jonathan Foulkes 
 

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Xmlunit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmlunit-general

Reply via email to