Blob Blame History Raw
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>XSL User Stylesheet</title><link rel="stylesheet" type="text/css" href="manual.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /><link rel="home" href="index.html" title="DocBook to LaTeX Publishing" /><link rel="up" href="sec-custom.html" title="Chapter 4. Customization" /><link rel="prev" href="sec-pi-usage.html" title="Using Processing Instructions" /><link rel="next" href="sec-custom-latex.html" title="Customized LaTeX style" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">XSL User Stylesheet</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-pi-usage.html">Prev</a> </td><th width="60%" align="center">Chapter 4. Customization</th><td width="20%" align="right"> <a accesskey="n" href="sec-custom-latex.html">Next</a></td></tr></table><hr /></div><div class="section" title="XSL User Stylesheet"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="idm159016"></a>XSL User Stylesheet</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="ch04s04.html#sec-param-stylesheet">Changing the XSL parameter values</a></span></dt><dt><span class="section"><a href="ch04s04.html#sec-custom-stylesheet">Overriding some templates</a></span></dt></dl></div><p>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
  <code class="option">-p <em class="replaceable"><code>custom.xsl</code></em></code>.</p><div class="section" title="Changing the XSL parameter values"><div class="titlepage"><div><div><h3 class="title"><a id="sec-param-stylesheet"></a>Changing the XSL parameter values</h3></div></div></div><p>
   The parameters can be stored in a user defined XSL stylesheet. An example of
   configuration stylesheet is given with this manual:
  </p><pre class="programlisting">&lt;?xml version='1.0' encoding="iso-8859-1"?&gt;
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'&gt;

&lt;!-- Target Database set by the command line

&lt;xsl:param name="target.database.document"&gt;olinkdb.xml&lt;/xsl:param&gt;
--&gt;

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

&lt;!-- Use the literal scaling feature --&gt;
&lt;xsl:param name="literal.extensions"&gt;scale.by.width&lt;/xsl:param&gt;

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

&lt;!-- Put the dblatex logo --&gt;
&lt;xsl:param name="doc.publisher.show"&gt;1&lt;/xsl:param&gt;

&lt;!-- Show the list of examples too --&gt;
&lt;xsl:param name="doc.lot.show"&gt;figure,table,example&lt;/xsl:param&gt;

&lt;!-- DocBook like description --&gt;
&lt;xsl:param name="term.breakline"&gt;1&lt;/xsl:param&gt;

&lt;!-- Manpage titles not numbered --&gt;
&lt;xsl:param name="refentry.numbered"&gt;0&lt;/xsl:param&gt;

&lt;xsl:template match="parameter"&gt;
  &lt;xsl:variable name="name" select="."/&gt;
  &lt;xsl:variable name="target" select="key('id',$name)[1]"/&gt;

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

&lt;xsl:template match="sgmltag[@class='xmlpi']"&gt;
  &lt;xsl:variable name="name" select="normalize-space(.)"/&gt;
  &lt;xsl:variable name="nameref" select="concat('pi-',translate($name,' ','_'))"/&gt;
  &lt;xsl:variable name="target" select="key('id',$nameref)[1]"/&gt;

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

&lt;/xsl:stylesheet&gt;
</pre></div><div class="section" title="Overriding some templates"><div class="titlepage"><div><div><h3 class="title"><a id="sec-custom-stylesheet"></a>Overriding some templates</h3></div></div></div><p>
   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.
  </p><p>
  You can of course split your templates in several files, and import each of
  them in the main user stylesheet by calling <code class="literal">xsl:import</code>.
  </p><div class="example"><a id="idp2327496"></a><p class="title"><strong>Example 4.2. Overriding templates</strong></p><div class="example-contents"><pre class="programlisting">
&lt;?xml version='1.0' encoding="iso-8859-1"?&gt;
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'&gt;
 
&lt;!-- Let's import our own XSL to override the default behaviour. --&gt;
&lt;xsl:import href="mystyle.xsl"/&gt;

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

&lt;/xsl:stylesheet&gt;
  </pre></div></div><br class="example-break" /></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-pi-usage.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sec-custom.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-custom-latex.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Using Processing Instructions </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Customized LaTeX style</td></tr></table></div></body></html>