Debian Codegraph @

docs/xhtml/manual/ch04s04.html

raw
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!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.79.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"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="idp2102"></a>XSL User Stylesheet</h2></div></div></div><div class="toc"><dl class="toc"><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,
3 and/or to override some of the dblatex XSL templates. The user stylesheet is
4 specified by using the option
5 <code class="option">-p <em class="replaceable"><code>custom.xsl</code></em></code>.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-param-stylesheet"></a>Changing the XSL parameter values</h3></div></div></div><p>
6 The parameters can be stored in a user defined XSL stylesheet. An example of
7 configuration stylesheet is given with this manual:
8 </p><pre class="programlisting">&lt;?xml version='1.0' encoding="iso-8859-1"?&gt;
9 &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'&gt;
10
11 &lt;!-- Target Database set by the command line
12
13 &lt;xsl:param name="target.database.document"&gt;olinkdb.xml&lt;/xsl:param&gt;
14 --&gt;
15
16 &lt;!-- Use the Bob Stayton's Tip related to olinking --&gt;
17 &lt;xsl:param name="current.docid" select="/*/@id"/&gt;
18
19 &lt;!-- Use the literal scaling feature --&gt;
20 &lt;xsl:param name="literal.extensions"&gt;scale.by.width&lt;/xsl:param&gt;
21
22 &lt;!-- We want the TOC links in the titles, and in blue. --&gt;
23 &lt;xsl:param name="latex.hyperparam"&gt;colorlinks,linkcolor=blue,pdfstartview=FitH&lt;/xsl:param&gt;
24
25 &lt;!-- Put the dblatex logo --&gt;
26 &lt;xsl:param name="doc.publisher.show"&gt;1&lt;/xsl:param&gt;
27
28 &lt;!-- Show the list of examples too --&gt;
29 &lt;xsl:param name="doc.lot.show"&gt;figure,table,example&lt;/xsl:param&gt;
30
31 &lt;!-- DocBook like description --&gt;
32 &lt;xsl:param name="term.breakline"&gt;1&lt;/xsl:param&gt;
33
34 &lt;!-- Manpage titles not numbered --&gt;
35 &lt;xsl:param name="refentry.numbered"&gt;0&lt;/xsl:param&gt;
36
37 &lt;xsl:template match="parameter"&gt;
38 &lt;xsl:variable name="name" select="."/&gt;
39 &lt;xsl:variable name="target" select="key('id',$name)[1]"/&gt;
40
41 &lt;xsl:choose&gt;
42 &lt;xsl:when test="count($target) &amp;gt; 0"&gt;
43 &lt;!-- Hot link to the parameter refentry --&gt;
44 &lt;xsl:call-template name="hyperlink.markup"&gt;
45 &lt;xsl:with-param name="linkend" select="$name"/&gt;
46 &lt;xsl:with-param name="text"&gt;
47 &lt;xsl:apply-imports/&gt;
48 &lt;/xsl:with-param&gt;
49 &lt;/xsl:call-template&gt;
50 &lt;!-- Index entry for this parameter --&gt;
51 &lt;xsl:text&gt;\index{Parameters!&lt;/xsl:text&gt;
52 &lt;xsl:value-of select="$name"/&gt;
53 &lt;xsl:text&gt;}&lt;/xsl:text&gt;
54 &lt;/xsl:when&gt;
55 &lt;xsl:otherwise&gt;
56 &lt;!--
57 &lt;xsl:message&gt;No reference for parameter: '&lt;xsl:value-of
58 select="$name"/&gt;'&lt;/xsl:message&gt;
59 --&gt;
60 &lt;xsl:apply-imports/&gt;
61 &lt;/xsl:otherwise&gt;
62 &lt;/xsl:choose&gt;
63 &lt;/xsl:template&gt;
64
65 &lt;xsl:template match="sgmltag[@class='xmlpi']"&gt;
66 &lt;xsl:variable name="name" select="normalize-space(.)"/&gt;
67 &lt;xsl:variable name="nameref" select="concat('pi-',translate($name,' ','_'))"/&gt;
68 &lt;xsl:variable name="target" select="key('id',$nameref)[1]"/&gt;
69
70 &lt;xsl:choose&gt;
71 &lt;xsl:when test="count($target) &amp;gt; 0"&gt;
72 &lt;!-- Hot link to the parameter refentry --&gt;
73 &lt;xsl:call-template name="hyperlink.markup"&gt;
74 &lt;xsl:with-param name="linkend" select="$nameref"/&gt;
75 &lt;xsl:with-param name="text"&gt;
76 &lt;xsl:apply-imports/&gt;
77 &lt;/xsl:with-param&gt;
78 &lt;/xsl:call-template&gt;
79 &lt;!-- Index entry for this parameter --&gt;
80 &lt;xsl:text&gt;\index{Processing Instructions!&lt;/xsl:text&gt;
81 &lt;xsl:value-of select="$name"/&gt;
82 &lt;xsl:text&gt;}&lt;/xsl:text&gt;
83 &lt;/xsl:when&gt;
84 &lt;xsl:otherwise&gt;
85 &lt;!--
86 &lt;xsl:message&gt;No reference for parameter: '&lt;xsl:value-of
87 select="$name"/&gt;'&lt;/xsl:message&gt;
88 --&gt;
89 &lt;xsl:apply-imports/&gt;
90 &lt;/xsl:otherwise&gt;
91 &lt;/xsl:choose&gt;
92 &lt;/xsl:template&gt;
93
94 &lt;/xsl:stylesheet&gt;
95 </pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-custom-stylesheet"></a>Overriding some templates</h3></div></div></div><p>
96 You can directly put the overriding templates in your XSL stylesheet, but do not
97 try to import the default dblatex stylesheets in it: it is automatically done by
98 the tool. So, just focus on the template to override and dblatex will ensure
99 that your definitions will get precedence over the dblatex ones.
100 </p><p>
101 You can of course split your templates in several files, and import each of
102 them in the main user stylesheet by calling <code class="literal">xsl:import</code>.
103 </p><div class="example"><a id="idp2116"></a><p class="title"><strong>Example 4.2. Overriding templates</strong></p><div class="example-contents"><pre class="programlisting">
104 &lt;?xml version='1.0' encoding="iso-8859-1"?&gt;
105 &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'&gt;
106
107 &lt;!-- Let's import our own XSL to override the default behaviour. --&gt;
108 &lt;xsl:import href="mystyle.xsl"/&gt;
109
110 &lt;!-- Let's patch directly a template here --&gt;
111 &lt;xsl:template match="article" mode="docinfo"&gt;
112 &lt;xsl:apply-imports/&gt;
113 &lt;xsl:text&gt;\let\mymacro=\DBKrelease&lt;/xsl:text&gt;
114 &lt;/xsl:template&gt;
115
116 &lt;/xsl:stylesheet&gt;
117 </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>