Mar 10
|
Transforming XML in Java is achieved using a Transformer. To use an XSL file for the transformation involves first creating Templates instance which can then be used to create the required Transformer.
TransformerFactory factory = TransformerFactory.newInstance(); Templates template = factory.newTemplates( new StreamSource(new FileInputStream(xslPath))); Transformer transformer = template.newTransformer(); Source source = new StreamSource(new FileInputStream(xmlInputPath)); Result result = new StreamResult(new FileOutputStream(xmlOutputPath)); transformer.transform(source, result);