This Maven plugin automatically formats all XML files in your project. It will skip changing an XML file if it is already in the correct format.
Internally it uses Dom4j's advanced formatter, allowing you to easily control many settings such as the indentation level, padding, encoding, XML declaration line, newline characters, encoding and so on. You can use a comment block or CDATA if you'd like to preserve specific formatting (eg legal messages).
This plugin has been tested with large projects that use many XML files for Maven POMs and Simple Binary Encoding schemas. The plugin also uses a test suite to verify the correct formatting of complex XML files (see test XML).
Ready to format? Take a look at the usage instructions.