Code Snippet

Just another Code Snippet site

[Java] Transform XML using XSL

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
// Apply the XSL Transformations on the XML file and store the result in a new file.
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(new File("/path/to/transform.xsl")));
transformer.transform(new StreamSource(new File("/path/to/input.xml")), new StreamResult(new File("/path/to/output.xml")));


Comments are currently closed.