This chapter covers the following topics:
Modifying individual XSLT processor parameters
Dealing with common customizations to the DocBook stylesheets.
If you use the default DocBook layout and want to adjust individual parameters, add
the --param "KEY=VALUE"
or the --stringparam "KEY=VALUE"
option. Both options can be added multiple times, and they work with the following
subcommands that specify the output formats:
epub
html
man
text
webhelp
The options pass on values for XSLT parameters directly to the XSLT processor, which is useful to temporarily overwrite style sheet parameters such as margins.
--param
/--stringparam
Use --param "KEY=VALUE"
or --stringparam "KEY=VALUE"
to set XSLT parameters on the command line.
However, if you want to specify your settings in the DC file instead, the respective parameter is named XSLTPARAM.
For larger or more complex modifications, such as adjustments of the title page layout, for example, it is advisable to create your own set of stylesheets instead.
For a list of XSLT parameters to modify, refer to one of the following references at http://docbook.sourceforge.net/release/xsl/current/doc/index.html:
HTML Parameter Reference: http://docbook.sourceforge.net/release/xsl/current/doc/html/index.html
FO Parameter Reference: http://docbook.sourceforge.net/release/xsl/current/doc/fo/index.html
Man Pages Parameter Reference: http://docbook.sourceforge.net/release/xsl/current/doc/manpages/index.html
By default, the DocBook stylesheets display the contents of a
variablelist
as a table. To change this temporarily,
set the parameter variablelist.as.table to 0
by executing the following command:
tux:~>
daps
-d PATH_TO_DC_FILE html \ --param1 "variablelist.as.table2=0"3 \ --param "variablelist.term.break.after=1" \ --stringparam1 "paper.type=A4"
As value of
VALUE can be an integer or XPATH expression
for | |
Name of the parameter to adjust. | |
Value for 2.
It will be passed on unmodified to the XSLT processor call that
creates the |
Alternatively, you can add the XSLTPARAM
parameter to the DC file of
your project and specify the parameters there. If doing so, also add
--stringparam
or --param
.
Either specify all parameters in a single line:
XSLTPARAM="--stringparam PARAM_NAME=VALUE --param PARAM_NAME=VALUE"
or in multiple lines (using +=
on subsequent rows):
XSLTPARAM="--stringparam PARAM_NAME=VALUE" XSLTPARAM+="$XSLTPARAM --param PARAM_NAME=VALUE"
You can set parameters in /etc/daps/config
or ~/.config/daps/dapsrc
using the
TXT_PARAMS parameter. Alternatively, set them from the command line, using the
--param
/--stringparam
options. By
default, the stylesheets specified with the STYLEROOT parameter or
the --styleroot
option are used for generating ASCII text output.
However, if you want to ignore any STYLEROOT definitions, set
TXT_IGNORE_STYLEROOT="yes"
in /etc/daps/config
or ~/.config/daps/dapsrc
or use the
--ignore-styleroot
option on the command line:
tux:~>
daps
-d PATH_TO_DC_FILE text --ignore-styleroot
This section describe how you can use customs stylesheets. There are many reasons why it would be preferable to create your own customization layer. Perhaps you want to change the layout or style of your project, change the behaviour how an element is processed or want to create a corporate style.
The reader should be aware of that some knowledge about XSLT is needed. Basic customizations like parameter changes can be done by simple adding a line with:
<xsl:param name="PARAMETER_NAME" select="VALUE"/>
The available parameters are format dependent and are listed in the "XSL Stylesheets Reference Documentation" (http://docbook.sourceforge.net/release/xsl/current/doc/param.html).
Best practice is to store the stylesheets in a xslt
directory as the top-level directory with different subdirectories for all
formats. Depending on which formats are supported, this top-level
directory could be integrated into your project directory like this:
YOUR_DOC_DIR/ | +-- DC-files +-- xml/ +--- your XML files... +-- xslt/ +-- fo/ +-- docbook.xsl +-- html/ +-- docbook.xsl +-- chunk.xsl +-- [additional formats, supported by DB XSL] +-- docbook.xsl
Finaly include the STYLEROOT
variable in your DC files,
pointing to the xslt directory.
It is recomended to also set the FALLBACK_STYLEROOT
variable which is used in case the custom stylesheets defined with
STYLEROOT
cannot be accessed.
In the following procedure we will create the directory stucture for customizations of the HTML output. For other formats, replace "html" with the approperiate name, e.g.: "fo".
Inside your project directory, create the styleroot hierarchy:
tux:~>
mkdir -p xslt/html
Make your customizations inside xslt/html/docbook.xsl
:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook"> <xsl:import href="http://docbook.sourceforge.net/release/xsl-ns/current/html/docbook.xsl"/> <!-- Your customizations go here --> </xsl:stylesheet>
In your DC files, set the STYLEROOT variable to xslt
.
STYLEROOT="xslt"
Useful tips and tricks on using DocBook and the DocBook stylesheets can be found in The DoCookBook—Recipes for DocBook Developers and Writers, available at http://doccookbook.sourceforge.net/ and in DocBook XSL Stylesheets: Reference Documentation available at http://docbook.sourceforge.net/release/xsl/current/doc/index.html.