OutputKeys.INDENT doesn't affect nodes, copied from another document
===

I read XML file into org.w3c.dom.Document, find a node by getElementsByTagName, append child from other document this way:

    foundNode.appendChild(document.adoptNode(othersDocumentNode.cloneNode(true)));

After that I save result to a StringWriter:

    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "20");
    transformer.transform(
        new DOMSource(document),
        new StreamResult(out)
    );

As a result I get document like this:

    <document>
                       <foundNode>
    <nestedContent>
      <content/>
    </nestedContent>
                       </foundonde>
    </document>

I.e. formatting doesn't affect nested content. I'd like all document to be formatted. How can I achieve this?

Thanx