Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version Control with XML diff and merge

I'm looking for an open source version control tool which can diff and merge XML files.

The difficulty I have to find such a tool is, that I need a correct merge of a XML file comparing the nodes and not the lines.

Any idea? Thanks!

like image 690
myborobudur Avatar asked Aug 05 '10 19:08

myborobudur


People also ask

Can git merge XML files?

It's possible to integrate our XML and JSON aware merge products into the Git merge process as either a merge driver or merge tool.

What is XML merge?

The XML Merge Component is a transformation component used to take incoming data from upstream SSIS source components and merge them into one SSIS column data based on the XML data structure defined in the component. This data can be then consumed by a downstream pipeline component.


1 Answers

Unfortunately, there's no one-size-fits-all solution to this problem. XML diffing is very sensitive to what YOU consider different. In one case the order of child nodes might be important, and in another case (maybe even in the same file) it might be irrelevant.

Take a look at XMLUnit. Even though it's aimed at unit-testing, it is a complete XML differencing engine. You have to tell it (in code) how to determine that two nodes are eligible for comparison, and then what to do with all the potential differences found (i.e. are they real or not, in your application). It detects an exhaustive list of "difference events" including

  • Attribute order
  • Number of attributes
  • Child node order
  • number of child nodes
  • implicit vs explicit attribute values
  • comment differences
  • doctype differences
  • namespace differences

And a whole bunch more. Any of these could be important or unimportant to your application, and only you can decide. It's worth a look, but it will take some work to get what you want.

like image 199
Jim Garrison Avatar answered Dec 13 '22 04:12

Jim Garrison