Chapter 1. DocBook XSL
Prev |  | Next

## Chapter 1. DocBook XSL

### Bob Stayton

$Id: publishing.html,v 1.1 2007/09/19 15:49:13 malo_pichot Exp $

Copyright © 2000 Bob Stayton

## Using XSL tools to publish DocBook documents

There is a growing list of tools to process DocBook documents using XSL stylesheets. Each tool implements parts or all of the XSL standard, which actually has several components:

Extensible Stylesheet Language (XSL)

  A language for expressing stylesheets written in XML. It includes the formatting object language, but refers to separate documents for the transformation language and the path language.

XSL Transformation (XSLT)

  The part of XSL for transforming XML documents into other XML documents, HTML, or text. It can be used to rearrange the content and generate new content.

XML Path Language (XPath)

  A language for addressing parts of an XML document. It is used to find the parts of your document to apply different styles to. All XSL processors use this component.

To publish HTML from your XML documents, you just need an XSLT engine. To get to print, you need an XSLT engine to produce formatting objects (FO), which then must be processed with a formatting object processor to produce PostScript or PDF output.

James Clark's XT was the first useful XSLT engine, and it is still in wide use. It is written in Java, so it runs on many platforms, and it is free ( http://www.jclark.com). XT comes with James Clark's nonvalidating parser XP, but you can substitute a different Java parser. Here is a simple example of using XT from the Unix command line to produce HTML: You'll need to alter your `CLASSPATH` environment variable to include the path to where you put the `.jar` files from the XT distribution.

    CLASSPATH=xt.jar:xp.jar:sax.jar
    export CLASSPATH
    java  com.jclark.xsl.sax.Driver filename.xml docbook/html/docbook.xsl > output.html

If you replace the HTML stylesheet with a formatting object stylesheet, XT will produce a formatting object file. Then you can convert that to PDF using FOP, a formatting object processor available for free from the Apache XML Project ( http://xml.apache.org). Here is an example of that two stage processing:

    CLASSPATH=xt.jar:xp.jar:sax.jar:fop.jar
    export CLASSPATH
    java  com.jclark.xsl.sax.Driver filename.xml docbook/fo/docbook.xsl > output.fo
    java  org.apache.fop.apps.CommandLine output.fo output.pdf

As of this writing, some other XSLT processors to choose from include:

- 4XSLT, written in Python, from FourThought LLC ( http://www.fourthought.com)

- Sablotron, written in C++, from Ginger Alliance ( http://www.gingerall.com)

- Saxon, written in Java, from Michael Kay ( http://users.iclway.co.uk/mhkay/saxon)

- Xalan, written in Java, from the Apache XML Project ( http://xml.apache.org)

- XML::XSLT,written in Perl, from Geert Josten and Egon Willighagen ( http://www.cpan.org)

For print output, these additional tools are available for processing formatting objects:

- XEP (written in Java) from RenderX ( http://www.renderx.com).

- PassiveTeX from Sebastian Rahtz (http://users.ox.ac.uk/~rahtz/passivetex/).

Prev | Up | Next
Preface | Home | A brief introduction to XSL