Transforming the XML Document

To transform the XML document using the XSLT stylesheet, run this command if you’re using Xalan:

java org.apache.xalan.xslt.Process -in greeting.xml -xsl greeting.xsl 
  -out greeting.html

For Saxon, the command looks like this:

java net.sf.saxon.Transform -o greeting.html greeting.xml greeting.xsl

If you’re using the Schema-aware version of Saxon, the name of the Java class is different:

java com.saxon.Transform -o greeting.html greeting.xml greeting.xsl

The command for the Altova XSLT engine is:

altovaxml /xslt1 greeting.xsl /in greeting.xml /out greeting.html

Finally, if you’re using Microsoft’s MSXSL, type this command:

msxsl greeting.xml greeting.xsl -o greeting.html

This command transforms the document greeting.xml, using the templates found in the stylesheet greeting.xsl. The results of the transformation are written to the file greeting.html. Check the output file in your favorite browser to make sure the transformation worked correctly.

Note

This is one of the few times in this book we’ll cover the syntax of the command to run a transformation. The exception to this rule will be when you need to do something more advanced (pass parameters to a stylesheet, for example). Typically, all you need to know are the filenames of the XML, XSL, and output files, and the format of the command for your stylesheet processor.

Get XSLT, 2nd Edition 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.