title: Java: XML canonicalization
body: <p>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 <a href="http://www.java2s.com/Open-Source/Java-Document/XML/xom/nu/xom/canonical/Canonicalizer.java.htm" rel="noreferrer">this</a>, <a href="http://koders.com/java/fid80EBAB24CF0FD266C7AE01964FD77EAFA9430C46.aspx?s=base64#L34" rel="noreferrer">this</a>, and <a href="http://jcs.mobile-utopia.com/jcs/11015_Canonicalizer.java" rel="noreferrer">this</a>, but I can't make it to work :/</p>
  
  <p>Thanks,</p>
  
  <p>Ivan</p>
  
  <p>EDIT: I used the canonicalizer that was proposed down there, but I get strange results. To be more precize, this method doesn't delete white spaces between elements... This is what I get:</p>
  
  <pre><code>&lt;Metric xmlns="http://www.ibm.com/wsla" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="total_memory_consumption_metric" type="double" unit="Mbit" xsi:schemaLocation="http://www.ibm.com/wsla WSLA.xsd"&gt;                        &lt;Source&gt;ServiceProvider&lt;/Source&gt;                        &lt;MeasurementDirective resultType="double" xsi:type="StatusRequest"&gt;                              &lt;RequestURI&gt; ***unused*** &lt;/RequestURI&gt;                        &lt;/MeasurementDirective&gt;                  &lt;/Metric&gt;
  </code></pre>