code: void writeDocument(OutputStream outStream, Document doc) {
          DOMImplementationRegistry domRegistry = null;
          try {
              domRegistry = DOMImplementationRegistry.newInstance();
          // Fortify Mod: Broaden try block to capture all potential exceptions
          // } catch (Exception e) {
          //    LOGR.warning(e.getMessage());
          // }
          DOMImplementationLS impl = (DOMImplementationLS) domRegistry
                  .getDOMImplementation("LS");
          LSSerializer writer = impl.createLSSerializer();
          writer.getDomConfig().setParameter("xml-declaration", false);
          writer.getDomConfig().setParameter("format-pretty-print", true);
          LSOutput output = impl.createLSOutput();
          output.setEncoding("UTF-8");
          output.setByteStream(outStream);
          writer.write(doc, output);
          } catch (Exception e) {
              LOGR.warning(e.getMessage());
          }
      }
docs: Writes a DOM Document to the given OutputStream using the "UTF-8"
  encoding. The XML declaration is omitted.
  
  @param outStream
  The destination OutputStream object.
  @param doc
  A Document node.