Hey guys, is there any way to tell the Transformer (when serializing an xml document using DOM), to omit the standalone attribute?
Preferably without using a hack , i.e. ommitting the whole xml declaration and then prepending it manually.
Thanks
-Vic
My current code:
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); //Note nothing is changed
StreamResult result = new StreamResult(new StringWriter());
DOMSource source = new DOMSource(document);
transformer.transform(source, result);
return result.getWriter().toString();
Current:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<someElement/>
Intended:
<?xml version="1.0" encoding="UTF-8">
<someElement/>