I need to manage XML documents in Subversion but don’t want to manage the formatting which may turn out differently depending on who is editing the file.
I see two solutions: Either format the file each time with a known formatting before checking in. Or give svn a diff program that actively dismisses formatting from the diff algorithm. Ultimately the diff should of course support three-way merge actively ignoring the XML formatting.
What do you recommend?
(The same reasoning usually applies to code source files, but the problem is more difficult.)
I don’t have a lot of personal experience with such a setup.
For the second method (a custom diff), what I’ve found is an example, ‘API description for Netopeer repository library’ which is a detailed description of a setup with Subversion and, among other things, xmldiff.
For the other approach, converting to a know format before storing in Subversion, I recommend Canonical XML as the format. The xmllint tool, for instance, can convert to this format:
To integrate with Subversion, you could test in pre-commit that the submitted file is equal to the canonical file. A possible such script is my pre-commit using xmllint. See also the enforcer script for an example.