What\'s the easiest way to make a canonical form of a XML file in Java? Do you have some done code for that? I\'ve found several links on the net, like this, this, and this,
The Canonicalizer class at Apache XML Security project.
Initialize the library.
org.apache.xml.security.Init.init();
Convert your XML.
Canonicalizer canon = Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
byte canonXmlBytes[] = canon.canonicalize(yourXmlBytes);
String canonXmlString = new String(canonXmlBytes);
Another option is nu.xom.canonical.Canonicalizer if you're using XOM, or if you don't otherwise have a need for Apache XML Security.