Given the following XML structure:
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element root = document.createElement("root");
Element child = document.createElement("child");
root.appendChild(child);
And the following transformer with the specified output properties:
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://ift.tt/1fh1NGB", "4");
transformer.transform(new DOMSource(root), new StreamResult(System.out));
I get this expected result:
<?xml version="1.0" encoding="UTF-8"?><root>
<child/>
</root>
Which output properties do I need to produce the following output?
<?xml version="1.0" encoding="UTF-8"?>
<root>
<child />
</root>
I need something to get a line break after the xml header and a whitespace before the close of empty tags. (like formatting in Eclipse)
My transformer is the default com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.
No comments:
Post a Comment