Applying XSLT Stylesheets : Transformer « XML « Java Tutorial






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








33.11.Transformer
33.11.1.Source for the JAXP Transformation Application
33.11.2.Source for Transforming DOM Node to HTML with JAXP
33.11.3.Catch TransformerException
33.11.4.Transforming an XML File with XSL into a DOM Document
33.11.5.Applying XSLT Stylesheets
33.11.6.Create an XML file and attach an XSL
33.11.7.And now to attach an XSL
33.11.8.Formatting an XML file using Transformer