Transforming XML with XSLT
Exercise - Transform an XML document with an XSLT stylesheet
In this exercise you will transform an XML document using XSLT.
Create a directory on your computer's desktop.
Copy all the *.dll files from the CD to your newly created directory.
Copy all the *.exe files from the CD to your newly created directory.
Copy cimi2html.xsl and water.xml from the CD to your newly created directory.
Open a new terminal window by running cmd.exe from the Start menu's Run command.
Change directories to your newly created directory.
Transform the XML document into an HTML document using this command: xsltproc -o wa-
ter.html cimi2html.xsl water.xml .
Open the newly created file named water.html in your Web browser.
In this part of the exercise you will change the content of the output.
Open cimi2html.xsl in your text editor.
Add a signature as a footer; insert <p> Brought to you by [yourname]. </p> after the </ol> element
of the XSLT file.
Process the XML again: xsltproc -o water.html cimi2html.xsl water.xml .
Open and/or reload the output, water.html, in your browser.
Go to Step #2 and make some other changes until you get tired.
Displaying tabular data
Here is an other example of an XSLT file used to render an XML file. This example renders our cata- log.xml file. It too functions very much like a plain o' CSS file. You can transform it using xsltproc like this: xsltproc -o catalog.html catalog2html.xsl catalog.xml .
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- catalog2html.xsl -->
<xsl:output method="xml" omit-xml-declaration="no" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />