title: How to remove standalone attribute declaration in xml document?
body: <p>Im am currently creating an xml using Java and then I transform it into a String. The xml declaration is as follows:</p>
  
  <pre><code>DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
  Document doc = docBuilder.newDocument();
  doc.setXmlVersion("1.0");
  </code></pre>
  
  <p>For transforming the document into String, I include the following declaration: </p>
  
  <pre><code>TransformerFactory transfac = TransformerFactory.newInstance();
  Transformer trans = transfac.newTransformer();
  trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
  trans.setOutputProperty(OutputKeys.VERSION, "1.0");
  trans.setOutputProperty(OutputKeys.ENCODING,"UTF-8");
  trans.setOutputProperty(OutputKeys.INDENT, "yes");
  </code></pre>
  
  <p>And then I do the transformation: </p>
  
  <pre><code>StringWriter sw = new StringWriter();
  StreamResult result = new StreamResult(sw);
  DOMSource source = new DOMSource(doc);
  trans.transform(source, result);
  String xmlString = sw.toString();
  </code></pre>
  
  <p>The problem is that in the XML Declaration attributes, the standalone attribute is included and I don't want that, but I want the version and encoding attributes to appear: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  </code></pre>
  
  <p>Is there any property where that could be specified?</p>