I've looked at the answers to this question, and unfortunately none of them has helped me so far.

Not to beat about the bush, the second edition of C# in Depth is now in copy edit. I want to be able to see what the copy editor's done really easily, so I can reject or accept his changes.

We're using a modified form of docbook, but I'm happy enough looking at the raw XML source. All fine so far - except that when the copy editor makes a change, that can change the line wrapping. So something that used to read:

<para>Foo bar baz
 second line</para>

now reads

<para>Foo bar grontle
 baz second line</para>

Now the real change here is the insertion of "grontle". I don't care that "baz" has moved from the first line to the second line... but all the diff tools I've seen do.

I realise that one option would be to reformat the whole document (or possibly just whole paragraphs) into single lines... but that's then really hard to read, because diff tools don't wrap when they're displaying.

I'm sure I can manage with the tools I've got, but if anyone knows of anything better, I'd be really glad to hear about it. I suspect my publishers would too :)

(I've included the Windows tag here because I'd really need it to be available on Windows. I'd like to hear about any non-Windows software too, but only in case I could help to build it on Windows :)

link|improve this question

75% accept rate
1  
John Skeet is asking a question!!!! OMG!!! This has only ever happened 6 times before on SU! ;-) – Josh Apr 8 '10 at 22:59
feedback

4 Answers

up vote 4 down vote accepted

Looks like SourceGear DiffMerge will give you this, with its ruleset support for XML (and lots of other languages). I'm not sure if it will fix all your problems, because the example is of course a simplification of the actual program. I tried slightly more complex changes, and those seem to work fine too.

See the sample below for the diff you described

simple diff

link|improve this answer
I've just had a quick look with the real files, and it looks like it does the job perfectly. Thank you so much! – Jon Skeet Apr 9 '10 at 5:31
feedback

I had this same problem at a company not too long ago. They wanted to find a true "XML differ", and there don't appear to be any complete solutions out there.

The easiest solution is to run a pretty-print script on the XML first to normalize the line-endings and spacing, and then run the diff tool of choice (WinMerge is nice for windows). This drops a lot of the flotsam that most difftools will throw at you from XML, and is really easy to build a script around.

link|improve this answer
The trouble is that the XML already is pretty-printed, effectively - it's the insertions and deletions that change where lines are wrapped. I wonder whether I need something to reformat one file based on the words that occur at the ends of lines in another :( – Jon Skeet Apr 8 '10 at 20:47
feedback

SD Smart Differencer compares documents based on structure as opposed to actual layout.

There's an XML Smart Differencer. For XML, that means matching order of tags and content. It should note that the text string in the specific fragment you indicated was different. (It presently doesn't understand the XML notion of text in which whitespace is normalized vs. significant, but I suspect that won't hurt you a lot).

link|improve this answer
feedback

I'm the author of an XML diff tool (commercial software) that should do the job (and some more features). There is a test version (which is limited to Xml files of 100 KBs max.) for download here:

http://xmldifftool.com/download_en.html

A short introduction is also available here:

http://xmldifftool.com/xtcmanual_en.html

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.