rewrite the given xmlfile

@param xmlDoc xml file as a dom node
@param aloneTags a string array of empty tags
@param outputXmlHeader true to output xml header

@return the rewrited xml.
350797
public final String rewriteXml(
        Node xmlDoc,
        String aloneTags[],
        boolean outputXmlHeader
    ) {
        try {
            StringWriter sOut = new StringWriter();
            rewriteXml(
                sOut,
                xmlDoc,
                aloneTags,
                outputXmlHeader
            );

            return sOut.toString();
        } catch (Exception e) {
            e.printStackTrace();

            return null;
        }
    }
28432
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("streamId", _streamId);
    writer.taggedValue("streamKey", _streamKey);
  }
1313351
public static String stripFormattingfromXMLString(String xml) {
		try {
			Document document = DocumentUtilities.toDocument(xml);

			DOMImplementationRegistry registry = DOMImplementationRegistry
					.newInstance();
			DOMImplementationLS domImplementationLS = (DOMImplementationLS) registry
					.getDOMImplementation("LS");
			LSSerializer serializaer = domImplementationLS.createLSSerializer();

			serializaer.getDomConfig().setParameter("format-pretty-print",
					Boolean.FALSE);

			serializaer.getDomConfig().setParameter("xml-declaration",
					Boolean.TRUE);

			// otherwise UTF-16 is used by default
			LSOutput lsOutput = domImplementationLS.createLSOutput();
			lsOutput.setEncoding("UTF-8");
			ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
			lsOutput.setByteStream(byteStream);

			serializaer.write(document, lsOutput);

			return new String(byteStream.toByteArray(), "UTF-8");

		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		} catch (ClassCastException e) {
			throw new RuntimeException(e);
		}
	}
507359
public final String rewriteXml(
        Node xmlDoc,
        String aloneTags[]
    ) {
        return rewriteXml(
            xmlDoc,
            aloneTags,
            false
        );
    }
1360487
public static void writeXHTML(Document htmldoc, OutputStream out) throws IOException {
    javax.xml.transform.Result result = new StreamResult(out);
    // Use a transformer for pretty printing
    Transformer xformer;
    try {
      xformer = TransformerFactory.newInstance().newTransformer();
      xformer.setOutputProperty(OutputKeys.INDENT, "yes");
      // TODO: ensure the "meta" tag doesn't claim a different encoding!
      xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
      xformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, HTML_XHTML_TRANSITIONAL_DOCTYPE_PUBLIC);
      xformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, HTML_XHTML_TRANSITIONAL_DOCTYPE_SYSTEM);
      xformer.transform(new DOMSource(htmldoc), result);
    }
    catch(TransformerException e1) {
      throw new IOException(e1);
    }
    out.flush();
  }
927276
public void simpleFastWrite(Writer out)
            throws IOException, XmlModelWriterException
    {
        out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        
        if (_publicID != null && _systemID != null) {
            out.write("<!DOCTYPE ");
            out.write(_rootName);
            out.write(" PUBLIC \"");
            out.write(_publicID);
            out.write("\" \"");
            out.write(_systemID);
            out.write("\">\n");
        }
        
        writeElement(out, _doc.getDocumentElement(), 0);
    }
1767
public static void writeElementList(XMLOutput xmlOutput, String tagName, Iterable<String> listValues) throws IOException {
        writeElementList(xmlOutput, tagName, listValues.iterator());
    }
1133320
public void xmlWriteOn(FormattedWriter writer) throws IOException {
        writer.newLine();
        writer.startTag(XML_ITEM_MAP);
        writer.indent();
        for (int i = 0; i < _entry.length; i++) {
            Entry entry =  _entry[i];
            while (null != entry) {
                AbstractItemLink ail = entry.link;
                writer.newLine();
                ail.xmlShortWriteOn(writer);
                entry = entry.next;
            }
        }
        writer.outdent();
        writer.newLine();
        writer.endTag(XML_ITEM_MAP);
    }
1310268
public final void rewriteXml(
        Writer out,
        Node xmlDoc,
        String aloneTags[]
    ) {
        rewriteXml(
            out,
            xmlDoc,
            aloneTags,
            false
        );
    }
753530
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("referencedMsg", msgId);
    writer.newLine();
    writer.taggedValue("AOTicks", tick+","+prevTick);
    writer.newLine();
    writer.taggedValue("gatheredMEUuid", sourceMEUuid);
  }
93678
public static void writeXML(DocumentFragment fragment, OutputStream stream) throws IOException {
		assert fragment != null : AssertMessages.notNullParameter(0);
		assert stream != null : AssertMessages.notNullParameter(1);
		writeNode(fragment, stream);
	}
416335
public static void writeXmlNoSpace(Document doc, String encoding, Writer out)
        throws IOException {
        XMLSerializer ser = new XMLSerializer(out, getXmlNoSpace(encoding));
        
        ser.serialize(doc);
        out.close();
    }
1141475
protected final void xmlWriteChildrenOn(FormattedWriter writer) throws IOException
    {
        super.xmlWriteChildrenOn(writer);
        if (null != _references)
        {
            _references.xmlWriteChildrenOn(writer, XML_REFERENCES);
        }
    }
1329998
private void generatePackageXml(File packageFile, Collection<ArchiveEntry> files) throws Exception
    {
        getLog().info(String.format("Generating package.xml descriptor at [%s]", packageFile.getPath()));

        OutputFormat outputFormat = new OutputFormat("", true);
        outputFormat.setEncoding(this.encoding);
        OutputStream out = new FileOutputStream(packageFile);
        XMLWriter writer = new XMLWriter(out, outputFormat);
        writer.write(toXML(files));
        writer.close();
        out.close();
    }
1016370
function XmlDocument(xml) {
  xml && (xml = xml.toString().trim());

  if (!xml)
    throw new Error("No XML to parse!");

  // Expose the parser to the other delegates while the parser is running
  this.parser = sax.parser(true); // strict
  addParserEvents(this.parser);

  // We'll use the file-scoped "delegates" var to remember what elements we're currently
  // parsing; they will push and pop off the stack as we get deeper into the XML hierarchy.
  // It's safe to use a global because JS is single-threaded.
  delegates = [this];
  
  this.parser.write(xml);

  // Remove the parser as it is no longer needed and should not be exposed to clients
  delete this.parser;
}
1202200
public void startDocument(String encoding, Boolean standalone) throws IOException {
		@SuppressWarnings("unused")
		char apos = attributeUseApostrophe ? '\'' : '"';
		if (attributeUseApostrophe) {
			out.write("<?xml version='1.0'");
		} else {
			out.write("<?xml version=\"1.0\"");
		}
		if (encoding != null) {
			out.write(" encoding=");
			out.write(attributeUseApostrophe ? '\'' : '"');
			out.write(encoding);
			out.write(attributeUseApostrophe ? '\'' : '"');
			// out.write('\'');
		}
		if (standalone != null) {
			out.write(" standalone=");
			out.write(attributeUseApostrophe ? '\'' : '"');
			if (standalone.booleanValue()) {
				out.write("yes");
			} else {
				out.write("no");
			}
			out.write(attributeUseApostrophe ? '\'' : '"');
			// if(standalone.booleanValue()) {
			// out.write(" standalone='yes'");
			// } else {
			// out.write(" standalone='no'");
			// }
		}
		out.write("?>");
	}
1163778
public static void printDocument(Node _docOrNode, OutputStream _outStream) throws IOException {
        if (_docOrNode == null || _outStream == null) {
            throw new IOException("Cannot print (on) 'null' object");
        }

        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer transformer;
        try {
            transformer = tf.newTransformer();
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

            transformer.transform(new DOMSource(_docOrNode),
                 new StreamResult(new OutputStreamWriter(_outStream, "UTF-8")));
        } catch (UnsupportedEncodingException | TransformerException _ex) {
            throw new IOException("Could not print Document or Node.",_ex);
        }

    }