Lint and reformat output XML
Support linting and reformatting the output XML, unless explicitly disabled. Apart from making it easier for humans to interpret the output XML, this will make it easier for us to track output changes as we continue refactoring the code.
Supersedes #32.