title: PrettyPrinting. Ignoring whitespaces
body: <p>be gentle. </p>
  
  <p>I'm trying to use javax.xml.transform.Transformer to format some xml string to be indented / spaceless between the tags. If there are no spaces between the tags, it works ok. If there are it acts weird. I'll post an example. I tried to follow up on the following topic : <a href="http://forums.sun.com/thread.jspa?messageID=2054303#2699961" rel="nofollow noreferrer">http://forums.sun.com/thread.jspa?messageID=2054303#2699961</a>. No success. </p>
  
  <p>Code to follow : </p>
  
  <pre><code>DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     factory.setIgnoringElementContentWhitespace(true);
     DocumentBuilder builder = factory.newDocumentBuilder();
     DOMImplementation domImpl = builder.getDOMImplementation();
     DOMImplementationLS ls = (DOMImplementationLS) domImpl.getFeature("LS", "3.0");
     LSInput in = ls.createLSInput();
     in.setByteStream(new ByteArrayInputStream(input.getBytes()));
     LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,
       "http://www.w3.org/2001/XMLSchema");
     Document xmlInput = parser.parse(in);
  
     StringWriter stringWriter = new StringWriter();
     StreamResult xmlOutput = new StreamResult(stringWriter);
     TransformerFactory f = TransformerFactory.newInstance();
     f.setAttribute("indent-number", 2);
  
     Transformer transformer = f.newTransformer();
     transformer.setOutputProperty(OutputKeys.INDENT, "yes");
     transformer.setOutputProperty(OutputKeys.METHOD, "xml");
     transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
     transformer.transform(new DOMSource(xmlInput), xmlOutput);
  </code></pre>
  
  <p>If there's no interruption between tags </p>
  
  <pre><code>input : &lt;tag&gt;&lt;nested&gt;    hello   &lt;/nested&gt;&lt;/tag&gt;
  output : 
  &lt;tag&gt;
    &lt;nested&gt;    hello   &lt;/nested&gt;
  &lt;/tag&gt;
  </code></pre>
  
  <p>If there is  : </p>
  
  <pre><code>input : &lt;tag&gt;  &lt;nested&gt;    hello   &lt;/nested&gt;&lt;/tag&gt;
  output : 
  &lt;tag&gt;  &lt;nested&gt;    hello   &lt;/nested&gt;
  &lt;/tag&gt;
  </code></pre>
  
  <p>JVM 1.6. </p>
  
  <p>Is something obvious wrong here ? </p>