List of utility methods to do XML String Transform
void | writeXML(Node node, String dtdFilename, String outputFileName) write XML getStringFromXML(node, dtdFilename, outputFileName); |
void | writeXml(OutputStream os, Node node, String encoding) write Xml TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); transformer.setOutputProperty("indent", "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, encoding); DOMSource source = new DOMSource(); source.setNode(node); StreamResult result = new StreamResult(); result.setOutputStream(os); ... |
void | writeXmlFile(Element doc, String filename) Writes an XML element to a given file try { Source source = new DOMSource(doc); File file = new File(filename); Result result = new StreamResult(file); Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(source, result); } catch (Exception e) { throw new RuntimeException(e); ... |
void | writeXmlResult(String xml, Writer w) write Xml Result StreamSource source = new StreamSource(new StringReader(xml)); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, ENCODING_UTF_8); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); ... |
String | xslString(final String xmlFile, final InputStream xslStream) xsl String return xslString(xmlFile, new StreamSource(xslStream)); |