I want to create a XML where blanks are replaced by . But the Java-Transformer escapes the Ampersand, so that the output is  
 
Try to use
element.appendChild (document.createCDATASection (" "));
instead of
element.setTextContent(...);
You'll get this in your xml: It may work if I understand correctly what you're trying to do.