Installing the DocBook stylesheets

The DocBook XSL stylesheets are a fairly large collection of files that can be downloaded as a collection from the DocBook SourceForge website where they are maintained. Go to http://docbook.sourceforge.net to reach the main project page. From there, select Files, and then scroll down to list of file archives. You'll generally want the latest stable version. Then download the archive and unpack it anywhere that's convenient.

If you prefer to use the package installation software on your operating system, the DocBook XSL stylesheets are also available in some package formats such as RPM. Check the DocBook Wiki packages page to see if there is an XSL package for your system. If you install from a package, you might want to note where the files install so you can refer to that path later.

Once you install the stylesheet distribution, you'll see these core subdirectories.

Table 3.1. Stylesheet subdirectories

SubdirectoryDescription
commonShared stylesheet modules, including languages.
docDocumentation for the stylesheets in browsable HTML.
extensionsProgram files that extend XSL for particular processors.
foStylesheet modules that produce XSL-FO output.
htmlStylesheet modules that produce HTML output.
imagesIcons and other images used in the output.
libStylesheet modules shared among many outputs.

There will be other directories containing documentation source in XML, stylesheet customizations for specialized output such as HTML Help, and other tool files. But if you ever need to copy just the basic set of files for running the stylesheets in their standard HTML or XSL-FO outputs, then these are the directories you will need (plus the VERSION file in the top-level directory).

The stylesheet distribution includes an INSTALL file. This is a Bash shell script that builds an XML catalog file using the xmlcatalog utility. It only works on systems with a Bash shell (not Windows unless it is under Cygwin), and it is not required for using the stylesheets. See Chapter 4, XML catalogs for more on setting up your own XML catalog file.

Note

You don't actually have to download the stylesheet files to use them. Most XSL processors, if given a URL instead of a filename, will fetch the stylesheet over the Internet. However, because the DocBook stylesheets are big and use many file modules, this process uses a lot of network bandwidth and greatly slows down the processing of your documents. But it can be used in a pinch when you are on a machine that doesn't have the stylesheets installed. For example:

xsltproc  \
   http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl \
   myfile.xml