Next / Previous / Contents / Shipman's homepage

15. Using the xsltproc processor

Before you try to apply your XSLT script, you may want to validate the XML file against its DTD. To do this, use the xmllint program:

    xmllint --valid --noout filename.xsl

where filename.xsl is the name of your XML file. Make sure your DTD is in the same directory and named in a <!DOCTYPE ...> declaration.

For example, if your XML document uses a DTD named trails.dtd and its root element is trails, its first line should look like this:

    <!DOCTYPE trails SYSTEM "trails.dtd">

To transform a file using XSLT, use xsltproc:

    xsltproc -o output.html stylesheet.xsl file.xml

where stylesheet.xsl is the XSLT stylesheet, file.xml is the XML input file, and output.html is the output file to be written.