Applying XSLT Stylesheets
import java.io.File;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class Main {
public static void main(String[] args) throws Exception{
StreamSource xmlFile = new StreamSource(new File(args[0]));
StreamSource xsltFile = new StreamSource(new File(args[1]));
TransformerFactory xsltFactory = TransformerFactory.newInstance();
Transformer transformer = xsltFactory.newTransformer(xsltFile);
StreamResult resultStream = new StreamResult(System.out);
transformer.transform(xmlFile, resultStream);
}
}
Related examples in the same category