List of utility methods to do XML Document to Writer
void | toWriter(Document doc, Writer writer) to Writer if (doc == null || writer == null) { return; try { Transformer tran = tf.newTransformer(); tran.setOutputProperty(OutputKeys.INDENT, "yes"); Source src = new DOMSource(doc); Result res = new StreamResult(writer); ... |
void | toXML(Document doc, Writer w, boolean indent) to XML try { Source source = new DOMSource(doc); Result result = new StreamResult(w); Transformer xformer = s_xformer_factory.newTransformer(); xformer.transform(source, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Configuration Exception writing XML: " + e); } catch (TransformerException e) { ... |
void | write(Writer out, Document doc) write try { new DefaultEditorKit().write(out, doc, 0, doc.getLength()); } catch (BadLocationException e) { throw new IOException(e.getMessage()); |
void | writeDocument(Document doc, Writer out) write Document DOMImplementationLS impl = (DOMImplementationLS) doc.getImplementation(); LSSerializer writer = impl.createLSSerializer(); DOMConfiguration config = writer.getDomConfig(); if (config.canSetParameter("format-pretty-print", Boolean.TRUE)) { config.setParameter("format-pretty-print", Boolean.TRUE); ByteArrayOutputStream baos = new ByteArrayOutputStream(); LSOutput output = impl.createLSOutput(); ... |
void | writeDocument(Document doc, Writer w) Writes the given document using the given writer. for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
writeNode(n, w);
|
void | writeDocument(Document document, Writer writer, Integer indent) Writes the given document to the given writer. TransformerFactory tf = TransformerFactory.newInstance(); try { Transformer trans = tf.newTransformer(); if (indent != null) { trans.setOutputProperty(OutputKeys.INDENT, "yes"); trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", String.valueOf(indent)); trans.transform(new DOMSource(document), new StreamResult(writer)); ... |
void | writeDocument(PrintWriter w, Document d) write Document w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); Node c = d.getFirstChild(); while (c != null) { writeNode(w, c, 0); c = c.getNextSibling(); |
void | writeDom(Document doc, Writer w) write Dom DOMSource docSource = new DOMSource(doc); Transformer transformer = getXmlTransformer(); transformer.transform(docSource, new StreamResult(w)); |
void | writeOutDOM(Document doc, Writer writer) write Out DOM Result result = new StreamResult(writer); DOMSource domSource = new DOMSource(doc); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty("omit-xml-declaration", "yes"); transformer.transform(domSource, result); |
void | writeXML(final Document doc, final Writer writer) Write the document to a writer. writeXML(doc, writer, null); |