Transforming XML with XSLT

StreamSource input =
											new StreamSource(new File("document.xml"));
											StreamSource stylesheet =
											new StreamSource(new File("style.xsl"));
											StreamResult output =
											new StreamResult(new File("out.xml"));
											TransformerFactory tf =
											TransformerFactory.newInstance();
											Transformer tx = tf.newTransformer(stylesheet);
											tx.transform(input, output);

XSLT is a standard for transforming XML documents from one format to another using an XSL stylesheet. The javax.xml.transform package is the API for using the XSLT transformation standard in Java. XSL stands for Extensible Stylesheet Language. XSLT is XSL Transformation, and it allows you to completely restructure an XML document. In general, when using XSLT, you have an input XML document and ...

Get Java™ Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.