XSL User Stylesheet
Prev | Chapter 4. Customization | Next

## XSL User Stylesheet

You can provide your own XSL stylesheet to set some of the XSL parameters, and/or to override some of the dblatex XSL templates. The user stylesheet is specified by using the option `-p `custom.xsl``.

### Changing the XSL parameter values

The parameters can be stored in a user defined XSL stylesheet. An example of configuration stylesheet is given with this manual:

    <?xml version='1.0' encoding="iso-8859-1"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>

    <!-- Target Database set by the command line

    <xsl:param name="target.database.document">olinkdb.xml</xsl:param>
    -->

    <!-- Use the Bob Stayton's Tip related to olinking -->
    <xsl:param name="current.docid" select="/*/@id"/>

    <!-- We want the TOC links in the titles, and in blue. -->
    <xsl:param name="latex.hyperparam">colorlinks,linkcolor=blue,pdfstartview=FitH</xsl:param>

    <!-- Put the dblatex logo -->
    <xsl:param name="doc.publisher.show">1</xsl:param>

    <!-- Show the list of examples too -->
    <xsl:param name="doc.lot.show">figure,table,example</xsl:param>

    <!-- DocBook like description -->
    <xsl:param name="term.breakline">1</xsl:param>

    <!-- Manpage titles not numbered -->
    <xsl:param name="refentry.numbered">0</xsl:param>

    <xsl:template match="parameter">
      <xsl:variable name="name" select="."/>
      <xsl:variable name="target" select="key('id',$name)[1]"/>

      <xsl:choose>
      <xsl:when test="count($target) &gt; 0">
        <!-- Hot link to the parameter refentry -->
        <xsl:call-template name="hyperlink.markup">
          <xsl:with-param name="linkend" select="$name"/>
          <xsl:with-param name="text">
            <xsl:apply-imports/>
          </xsl:with-param>
        </xsl:call-template>
        <!-- Index entry for this parameter -->
        <xsl:text>\index{Parameters!</xsl:text>
        <xsl:value-of select="$name"/>
        <xsl:text>}</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <!--
        <xsl:message>No reference for parameter: '<xsl:value-of
        select="$name"/>'</xsl:message>
        -->
        <xsl:apply-imports/>
      </xsl:otherwise>
      </xsl:choose>
    </xsl:template>

    </xsl:stylesheet>

### Overriding some templates

You can directly put the overriding templates in your XSL stylesheet, but do not try to import the default dblatex stylesheets in it: it is automatically done by the tool. So, just focus on the template to override and dblatex will ensure that your definitions will get precedence over the dblatex ones.

You can of course split your templates in several files, and import each of them in the main user stylesheet by calling `xsl:import`.

Example 4.1. Overriding templates

    <?xml version='1.0' encoding="iso-8859-1"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>

    <!-- Let's import our own XSL to override the default behaviour. -->
    <xsl:import href="mystyle.xsl"/>

    <!-- Let's patch directly a template here -->
    <xsl:template match="article" mode="docinfo">
      <xsl:apply-imports/>
      <xsl:text>\let\mymacro=\DBKrelease</xsl:text>
    </xsl:template>

    </xsl:stylesheet>

Prev | Up | Next
Setting Command line Parameters | Home | Customized LaTeX style