Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
Applies to DAPS 3.1

9 Customizing Layout of the Output Formats

This chapter covers the following topics:

  • Modifying individual XSLT processor parameters

  • Dealing with common customizations to the DocBook stylesheets.

9.1 Modifying Individual XSLT Processor Parameters

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

  • pdf

  • 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.

Note
Note: XSLTPARAM And --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:

Example 9.1: Adjusting the Layout of Variable Lists

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"

1

As value of --param or --stringparam, add an xsltproc parameter in the form of PARAM_NAME=VALUE" .

VALUE can be an integer or XPATH expression for --param and a string for --stringparam.

2

Name of the parameter to adjust.

3

Value for 2. It will be passed on unmodified to the XSLT processor call that creates the .fo file or HTML from the profiled XML sources.

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"

9.2 Specifying the Layout for ASCII Text Output

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

9.3 Customizing the DocBook Stylesheets

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.

Important
Important

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:

Example 9.2: Best Practice File Hierarchy
        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.

Note
Note

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".

Procedure 9.1: Create a Styleroot Directory for the HTML Format
  1. Inside your project directory, create the styleroot hierarchy:

    tux:~> mkdir -p xslt/html
  2. Make your customizations inside xslt/html/docbook.xsl:

    Example 9.3: General Customization Layer
    <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>
  3. 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.

Print this page