Chapter 6. Using stylesheet parameters

Table of Contents

Parameters on the command line
Parameters in a file

The DocBook XSL stylesheets have many parameters that can be used to control various aspects of the output that the stylesheets generate. A parameter is simply a named variable that you give a value to. For example, with parameters you can control what level of headings appear in the tables of contents, whether you want a CSS stylesheet attached to your HTML output, and what body type size you want for your print output.

The great thing about parameters is that they are very easy to use. They are the easiest way to customize the behavior of the stylesheets. You can specify parameter values on the command line, or you can create a file full of them to use with each processing job. The only downside to parameters is when there is no parameter for some particular change you would like to see. You can certainly request additional parameters of the DocBook stylesheet maintainers at http://docbook.sourceforge.net, but that would not solve your immediate problem.

In order to use parameters, you have to know the names of available parameters, what they do, and what values to assign them. An up-to-date set of HTML reference pages is included in each DocBook XSL distribution in the doc/html and doc/fo directories. You can also bookmark these online reference links that provide the information for the latest distribution:

If you are not using the latest version, you should probably consult the reference pages that came with your distribution.

Parameters on the command line

Each of the XSL processors use slightly different syntax to specify parameters on the command line. Here are some examples that set two parameters: html.stylesheet to specify the name of a CSS stylesheet to associate with your HTML files, and admon.graphics to turn on the icon graphics for admonition elements such as note.

Using parameters with xsltproc:
xsltproc  --output myfile.html  \
  --stringparam  html.stylesheet "corpstyle.css"  \
  --stringparam  admon.graphics 1 \
  docbook.xsl  myfile.xml

Put parameters at end of line with Saxon:
java  com.icl.saxon.StyleSheet  -o myfile.html  myfile.xml  docbook.xsl \
  html.stylesheet="corpstyle.css" \
  admon.graphics=1

Options including -param can be in any order with Xalan:
java  org.apache.xalan.xslt.Process  -out myfile.html  -in myfile.xml \
  -xsl docbook.xsl \
  -param  html.stylesheet "corpstyle.css" \
  -param  admon.graphics 1

If a parameter value includes spaces or special characters, put it in quotes.