I want to create a XML where blanks are replaced by . But the Java-Transformer escapes the Ampersand, so that the output is  
The solution is very funny:
Node disableEscaping = document.createProcessingInstruction(StreamResult.PI_DISABLE_OUTPUT_ESCAPING, "&");
Element element = document.createElement("element");
element.setTextContent(" ");
document.appendChild(disableEscaping );
document.appendChild(element);
Node enableEscaping = document.createProcessingInstruction(StreamResult.PI_ENABLE_OUTPUT_ESCAPING, "&");
document.appendChild(enableEscaping )
So basically you need put your code between escaping element.