I want to be able to do a 3-way merge of XHTML documents:
- Start with some original copy of the document
- One user edits a copy of the original document
- Another user edits a separate copy of the original document
- Need a tool to merge (automatically and/or visually) the changes made by the two users.
Note:
- I want to include this functionality in commercial software: so I prefer something that's free-as-in-beer and/or open source, instead of a commercial tool.
- I suspect it's better if the tool is XML-aware, than to try to use software like
diff3
which implements 3-way merge of flat text - Given that all three input documents are valid XHTML documents, the resulting output document should validate too
Tools I've fo开发者_如何转开发und include:
- The "3DM" XML 3-way Merging and Differencing Tool
- Fuego Core XML Diff and Patch Tool
- XmlDiff (lately from the GotDotNet site which has been shut down, but maybe it's living on as a component of XML Notepad)
The first of the above (i.e. "3DM") says explicitly that it implements 3-way merges.
I don't know about the other two: whether "diff" followed by "patch" is equivalent to a 3-way merge, or instead whether "patch" can only reapply the diff to the original file (and not to a third, altered copy of the file)
Can you recommend some software (from the list above, or elsewhere) for this purpose, and/or a description of a merge algorithm?
Edit: Matching, diffing and merging XML is another article from 2008, which includes a brief survey of various algorithms and references to various implementations.
Edit #2: The author confirmed that the Fuego Core XML Diff and Patch Tool can only patche the original file, and doesn't implement 3-way merging.
I don't have a free solution, I'm afraid, but Project: Merge is a cheap XML comparison and merge tool which can be controlled through the command line. It could probably plug straight in to your application.
I can add to your collection DeltaXML - they do not claim diff3, but worth considering.
One free alternative would be to do
$ xmlstarlet fo before.xml > before.xml
$ xmlstarlet fo after.xml > after.xml
and then do
$ diff before.xml after.xml
to create a patch of the XML difference. It's free and simple.
精彩评论