XSLT documentation examples



1   Overview
2   Screenshots
3   Browse the source code
4   Get the files
5   Use the files

1. Overview.

XSLT is both an XML-based language and a way to transform XML-based data files into files of other types. It (XSLT) can be used, for example, to convert a book or article that's stored in an XML-based document format to an HTML web page.

Since XSLT programs (also known as XSLT stylesheets) can generate a large number of output formats, they may simplify the process of maintaining documentation for a project. The basic idea is that a document can be written once, in an XML-based document format, and then transformed to other formats as necessary.

This approach to documentation isn't unique to XSLT. LaTeX, Restructured Text, etc., are often used to do something similar. But XML-based formats are widely used, for documents as well as for data files in general, and XSLT is uniquely suited to working with files of this type.

Additionally, the major web browsers support XSLT internally. This means that, theoretically, web pages can be written initially in XML plus XSLT and then converted easily from there to other formats.

But XSLT can be a bit difficult to learn. So, both as the beginnings of a tutorial and as the start of a possibly useful toolset, this page provides two related XSLT stylesheets that can be used to transform XML documents written using a simple format into DokuWiki and HTML, respectively.

PDF output can be created by running the HTML output through a Linux program named wkhtmltopdf.

Technical note: The XSLT stylesheet provided for XML to DokuWiki transformation includes an interesting feature. If DokuWiki markup is present (either intentionally or accidentally) in the input, the stylesheet in question tries to “escape” the text automatically. People who need to do XSLT text-edit operations may find the associated code useful.

2. Screenshots.

Here's what the DokuWiki and HTML output formats look like (viewed using the Epiphany web browser). The same XML input document is used in both cases:


XSLT DokuWiki output


XSLT HTML output

The PDF output is very similar to the HTML output.

3. Browse the source code.

If you'd like to browse the XSLT source code, use these links:

XSLT file for XML to DokuWiki

XSLT file for XML to HTML

4. Get the files.

To download everything that's available, right-click on this ZIP-file link and save the ZIP file to disk.

After you've saved the ZIP file, open the file and read the text file readme.txt that's provided inside.

5. Use the files.

The readme.txt file mentioned previously includes basic information about this package. For more detailed information, including a description of the XML input format used, see the comments near the top of each of the .xsl files.

Some notes about requirements:

To generate DokuWiki and HTML output, you'll need xsltproc, which is provided with most Linux distros.

You can use Xalan instead of xsltproc. If you'd like to do so, see the comments near the top of each of the .xsl files.

Any web browser that supports CSS standards may be used to view the HTML output. To view the DokuWiki output, you'll need a web browser of this type and DokuWiki (including the DokuWiki xterm plugin).

To generate PDF output, wkhtmltopdf is recommended, but pdf2email is also useful. For more information about the latter two programs, visit:



Hosting provided by Zymic.

For acknowledgments related to CSS and other code used, click here.

Linked or embedded works (software, books, articles, etc.) are presented under their own licenses.

Other unique content on this page, excluding screenshots, is distributed under the following license: C.C. Attribution NonCommercial ShareAlike 3.0. In some cases, screenshots are distributed under the same license. In other cases, the associated program's license applies.

image Valid XHTML 1.0