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);

written by objects \\ tags: , , ,

One Ping to “How to transform XML using XSL?”

  1. How to convert all xml element names to lower case? | web development helpdesk Says:

    […] How to transform XML using XSL? […]

Leave a Reply

You must be logged in to post a comment.