code: public static void writeDocumentToOutputStream(DomDocument document, OutputStream outputStream) {
      StreamResult result = new StreamResult(outputStream);
      transformDocumentToXml(document, result);
    }
docs: Writes a {@link DomDocument} to an {@link OutputStream} by transforming the DOM to XML.
  
  @param document  the DOM document to write
  @param outputStream  the {@link OutputStream} to write to