Interfacing Xalan to Java

Xalan is actually one of the easier XSLT processors to interface to Java, despite its size. To show how this works, I create a new Java class, xalanjava, which you can call like this to perform an XSLT transformation:

C:\>java xalanjava planets.xml planets.xsl planets.html 

To create an XSLT transformation, I start by creating an object of the TransformerFactoryclass in the xalanjavaclass:

 import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerConfigurationException; import java.io.FileOutputStream; import ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.