XSLT processors

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

To view the results of applying XSLT transformations on an XML document, you must have access to an XSLT processor. Two widely used XSLT processors include Apache Xalan and Saxon. If you have one of these processors installed, you can generate an input document by applying a stylesheet to an output document. For example, in Saxon, the command for doing such a transformation is as shown below:

java -jar saxon.jar -o output.xml input.xml test.xsl

This generates an output document called output.xml from an input document called input.xml by applying a stylesheet called test.xsl.

The alternative to using a standalone XSLT processor is to use the built-in XSLT capabilities of a Web browser. Current versions of most browsers, including IE 6.0 and Netscape 7.0, have an XSLT processor already built in and can automatically transform XML documents before displaying them. This allows you to display arbitrary XML documents on the Web, with their content automatically formatted in any desired style. All that is needed is to write an appropriate stylesheet that specifies how to transform the XML document into an HTML one.

Suppose you want to apply a stylesheet called test.xsl to an XML document to convert it into an HTML document. You can perform the XSLT transformation and view the results using any XSLT-capable browser, such as IE 6.0 or Netscape 7.0. To do this, you first need to edit the input XML document by adding the following processing instruction at the start:

<?xml-stylesheet href="test.xsl" type="text/xsl"?>

In this instruction, the href attribute specifies the name and location of the stylesheet and the type attribute specifies its format. If you then open the XML document in a suitable browser, the specified XSL stylesheet is automatically applied to the document and the HTML document resulting from the transformation is displayed in the browser.


<< back next >>





Copyright © CHARLES RIVER MEDIA, INC., Massachusetts (USA) 2003
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "The MathML Handbook" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

CHARLES RIVER MEDIA, INC., 20 Downer Avenue, Suite 3, Hingham, Massachusetts 02043, United States of America