blob: cef71d84ec68d757667e79dfb16c824af23c743b [file] [log] [blame]
de97ab7e72005-11-27 18:19:40 +00001<?xml version="1.0"?> <!-- -*- sgml -*- -->
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
4<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
5<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk-common.xsl"/>
6<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/manifest.xsl"/>
7<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk-code.xsl"/>
8
9
10<!-- use 8859-1 encoding -->
11<xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
12
13<!-- set various parameters -->
14<xsl:param name="use.id.as.filename" select="'1'"/>
15<xsl:param name="chunker.output.indent" select="'yes'"/>
16<!-- set chunking at the chapter level only -->
17<xsl:param name="chunk.section.depth" select="'0'"/>
18<!-- set toc-levels -->
19<xsl:param name="generate.toc">
20set toc,title
21book toc,title,figure,table,example,equation
22chapter toc,title
23section toc
24sect1 toc
25sect2 toc
26sect3 toc
27sect4 nop
28sect5 nop
29qandaset toc
30qandadiv toc
31appendix toc,title
32article/appendix nop
33article nop
34preface toc,title
35reference toc,title
36</xsl:param>
37
38
39<!-- properties common to html + fo ................................... -->
40
41<!-- we like '1.2 Title' -->
42<xsl:param name="section.autolabel" select="'1'"/>
43<xsl:param name="section.label.includes.component.label" select="'1'"/>
44
45<!-- Do not put 'Chapter' at the start of eg 'Chapter 1. Doing This' -->
46<xsl:param name="local.l10n.xml" select="document('')"/>
47<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
48 <l:l10n language="en">
49 <l:context name="title-numbered">
50 <l:template name="chapter" text="%n.&#160;%t"/>
51 </l:context>
52 </l:l10n>
53</l:i18n>
54
55<!-- per Bob Stayton: turn off xml:base processing pro tem -->
56<!-- should hopefully be fixed in next docbook stylesheets release (1.70) -->
57<xsl:template match="@fileref">
58 <xsl:value-of select="."/>
59</xsl:template>
60
61<!-- end properties common to html + fo ............................... -->
62
63
64<!-- center everything at the top of a titlepage -->
65<xsl:attribute-set name="set.titlepage.recto.style">
66 <xsl:attribute name="align">center</xsl:attribute>
67</xsl:attribute-set>
68
69
70<!-- don`t put an expanded set-level TOC, only book titles -->
71<xsl:template match="book" mode="toc">
72 <xsl:param name="toc-context" select="."/>
73 <xsl:choose>
74 <xsl:when test="local-name($toc-context) = 'set'">
75 <xsl:call-template name="subtoc">
76 <xsl:with-param name="toc-context" select="$toc-context"/>
77 <xsl:with-param name="nodes" select="foo"/>
78 </xsl:call-template>
79 </xsl:when>
80 <xsl:otherwise>
81 <xsl:call-template name="subtoc">
82 <xsl:with-param name="toc-context" select="$toc-context"/>
83 <xsl:with-param name="nodes" select="part|reference
84 |preface|chapter|appendix
85 |article
86 |bibliography|glossary|index
87 |refentry
88 |bridgehead[$bridgehead.in.toc !=
890]"/>
90 </xsl:call-template>
91 </xsl:otherwise>
92 </xsl:choose>
93</xsl:template>
94
95
96<!-- custom footer -->
97<xsl:template name="footer.navigation">
98 <xsl:param name="prev" select="/foo"/>
99 <xsl:param name="next" select="/foo"/>
100 <xsl:param name="nav.context"/>
101
102 <xsl:variable name="home" select="/*[1]"/>
103 <xsl:variable name="up" select="parent::*"/>
104
105 <xsl:variable name="row1" select="count($prev) &gt; 0
106 or count($up) &gt; 0
107 or count($next) &gt; 0"/>
108
109 <xsl:variable name="row2" select="($prev != 0)
110 or (generate-id($home) != generate-id(.) or $nav.context = 'toc')
111 or ($chunk.tocs.and.lots != 0 and $nav.context != 'toc')
112 or ($next != 0)"/>
113 <div>
114 <xsl:if test="$row1 or $row2">
115 <br />
116 <table class="nav" width="100%" cellspacing="3" cellpadding="2" border="0" summary="Navigation footer">
117 <xsl:if test="$row1">
118 <tr>
119 <td rowspan="2" width="40%" align="left">
120 <xsl:if test="count($prev)>0">
121 <a accesskey="p">
122 <xsl:attribute name="href">
123 <xsl:call-template name="href.target">
124 <xsl:with-param name="object" select="$prev"/>
125 </xsl:call-template>
126 </xsl:attribute>
127 <xsl:text>&#060;&#060;&#160;</xsl:text>
128 <xsl:apply-templates select="$prev" mode="object.title.markup"/>
129 </a>
130 </xsl:if>
131 <xsl:text>&#160;</xsl:text>
132 </td>
133 <td width="20%" align="center">
134 <xsl:choose>
135 <xsl:when test="count($up)>0">
136 <a accesskey="u">
137 <xsl:attribute name="href">
138 <xsl:call-template name="href.target">
139 <xsl:with-param name="object" select="$up"/>
140 </xsl:call-template>
141 </xsl:attribute>
142 <xsl:call-template name="navig.content">
143 <xsl:with-param name="direction" select="'up'"/>
144 </xsl:call-template>
145 </a>
146 </xsl:when>
147 <xsl:otherwise>&#160;</xsl:otherwise>
148 </xsl:choose>
149 </td>
150 <td rowspan="2" width="40%" align="right">
151 <xsl:text>&#160;</xsl:text>
152 <xsl:if test="count($next)>0">
153 <a accesskey="n">
154 <xsl:attribute name="href">
155 <xsl:call-template name="href.target">
156 <xsl:with-param name="object" select="$next"/>
157 </xsl:call-template>
158 </xsl:attribute>
159 <xsl:apply-templates select="$next" mode="object.title.markup"/>
160 <xsl:text>&#160;&#062;&#062;</xsl:text>
161 </a>
162 </xsl:if>
163 </td>
164 </tr>
165 </xsl:if>
166 <xsl:if test="$row2">
167 <tr>
168 <td width="20%" align="center">
169 <xsl:choose>
170 <xsl:when test="$home != . or $nav.context = 'toc'">
171 <a accesskey="h">
172 <xsl:attribute name="href">
173 <xsl:call-template name="href.target">
174 <xsl:with-param name="object" select="$home"/>
175 </xsl:call-template>
176 </xsl:attribute>
177 <xsl:call-template name="navig.content">
178 <xsl:with-param name="direction" select="'home'"/>
179 </xsl:call-template>
180 </a>
181 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
182 <xsl:text>&#160;|&#160;</xsl:text>
183 </xsl:if>
184 </xsl:when>
185 <xsl:otherwise>&#160;</xsl:otherwise>
186 </xsl:choose>
187 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
188 <a accesskey="t">
189 <xsl:attribute name="href">
190 <xsl:apply-templates select="/*[1]" mode="recursive-chunk-filename"/>
191 <xsl:text>-toc</xsl:text>
192 <xsl:value-of select="$html.ext"/>
193 </xsl:attribute>
194 <xsl:call-template name="gentext">
195 <xsl:with-param name="key" select="'nav-toc'"/>
196 </xsl:call-template>
197 </a>
198 </xsl:if>
199 </td>
200 </tr>
201 </xsl:if>
202 </table>
203 </xsl:if>
204 </div>
205</xsl:template>
206
207
208<!-- qandaset styles -->
209<!-- these templates have been carefully tweaked to correct the -->
210<!-- horrible mess that docbook makes of dl/dt/dd tags. Edit with care -->
211<xsl:template match="qandaset">
212 <xsl:variable name="title" select="(blockinfo/title|title)[1]"/>
213 <xsl:variable name="toc">
214 <xsl:call-template name="dbhtml-attribute">
215 <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
216 <xsl:with-param name="attribute" select="'toc'"/>
217 </xsl:call-template>
218 </xsl:variable>
219
220 <xsl:variable name="toc.params">
221 <xsl:call-template name="find.path.params">
222 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
223 </xsl:call-template>
224 </xsl:variable>
225
226 <div class="{name(.)}">
227 <xsl:apply-templates select="$title"/>
228 <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
229 <xsl:call-template name="process.qanda.toc"/>
230 </xsl:if>
231 <xsl:apply-templates select="qandaentry|qandadiv"/>
232 </div>
233</xsl:template>
234
235
236<xsl:template match="qandadiv">
237 <br/>
238 <table width="100%" summary="Q and A Div" cellpadding="2" cellspacing="2" border="0">
239 <xsl:if test="blockinfo/title|title">
240 <tr class="qandadiv">
241 <td align="left" valign="top" colspan="2">
242 <xsl:call-template name="anchor">
243 <xsl:with-param name="conditional" select="0"/>
244 </xsl:call-template>
245 <xsl:apply-templates select="(blockinfo/title|title)[1]"/>
246 </td>
247 </tr>
248 </xsl:if>
249
250 <xsl:variable name="toc">
251 <xsl:call-template name="dbhtml-attribute">
252 <xsl:with-param name="pis"
253 select="processing-instruction('dbhtml')"/>
254 <xsl:with-param name="attribute" select="'toc'"/>
255 </xsl:call-template>
256 </xsl:variable>
257
258 <xsl:variable name="toc.params">
259 <xsl:call-template name="find.path.params">
260 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
261 </xsl:call-template>
262 </xsl:variable>
263
264 <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
265 <tr class="toc" colspan="2">
266 <td align="left" valign="top" colspan="2">
267 <xsl:call-template name="process.myqanda.toc"/>
268 </td>
269 </tr>
270 </xsl:if>
271 <xsl:apply-templates select="qandadiv|qandaentry"/>
272 </table>
273</xsl:template>
274
275
276<!-- put questions in bold -->
277<xsl:template match="question/para">
278 <b><xsl:apply-templates/></b>
279</xsl:template>
280
281<xsl:template match="question">
282 <xsl:variable name="deflabel">
283 <xsl:choose>
284 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
285 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
286 /@defaultlabel"/>
287 </xsl:when>
288 <xsl:otherwise>
289 <xsl:value-of select="$qanda.defaultlabel"/>
290 </xsl:otherwise>
291 </xsl:choose>
292 </xsl:variable>
293 <tr><td colspan="2"><xsl:text>&#160;</xsl:text></td></tr>
294 <tr class="{name(.)}">
295 <td align="left" valign="top">
296 <xsl:call-template name="anchor">
297 <xsl:with-param name="node" select=".."/>
298 <xsl:with-param name="conditional" select="0"/>
299 </xsl:call-template>
300 <xsl:call-template name="anchor">
301 <xsl:with-param name="conditional" select="0"/>
302 </xsl:call-template>
303 <b>
304 <xsl:apply-templates select="." mode="label.markup"/>
305 <xsl:if test="$deflabel = 'number' and not(label)">
306 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
307 </xsl:if>
308 </b>
309 </td>
310 <td align="left" valign="top">
311 <xsl:choose>
312 <xsl:when test="$deflabel = 'none' and not(label)">
313 <b><xsl:apply-templates select="*[name(.) != 'label']"/></b>
314 </xsl:when>
315 <xsl:otherwise>
316 <xsl:apply-templates select="*[name(.) != 'label']"/>
317 </xsl:otherwise>
318 </xsl:choose>
319 </td>
320 </tr>
321</xsl:template>
322
323
324<xsl:template name="process.myqanda.toc">
325 <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
326 <xsl:apply-templates select="qandaentry" mode="myqandatoc.mode"/>
327</xsl:template>
328
329
330<xsl:template name="process.qanda.toc">
331 <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
332 <xsl:apply-templates select="qandaentry" mode="qandatoc.mode"/>
333</xsl:template>
334
335
336<xsl:template match="qandadiv" mode="qandatoc.mode">
337<dl>
338 <dt><xsl:apply-templates select="title" mode="qandatoc.mode"/></dt>
339 <xsl:call-template name="process.qanda.toc"/>
340</dl>
341</xsl:template>
342
343
344<!-- this one is used at the top of the page -->
345<xsl:template match="question" mode="qandatoc.mode">
346 <xsl:variable name="firstch" select="(*[name(.)!='label'])[1]"/>
347 <xsl:variable name="deflabel">
348 <xsl:choose>
349 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
350 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
351 /@defaultlabel"/>
352 </xsl:when>
353 <xsl:otherwise>
354 <xsl:value-of select="$qanda.defaultlabel"/>
355 </xsl:otherwise>
356 </xsl:choose>
357 </xsl:variable>
358 <dd>
359 <xsl:apply-templates select="." mode="label.markup"/>
360 <xsl:if test="$deflabel = 'number' and not(label)">
361 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
362 </xsl:if>
363 <xsl:text> </xsl:text>
364 <a>
365 <xsl:attribute name="href">
366 <xsl:call-template name="href.target">
367 <xsl:with-param name="object" select=".."/>
368 </xsl:call-template>
369 </xsl:attribute>
370 <xsl:value-of select="$firstch"/>
371 </a>
372 </dd>
373</xsl:template>
374
375
376<!-- this one is used within table cells -->
377<xsl:template match="qandaentry" mode="myqandatoc.mode">
378 <xsl:apply-templates select="question" mode="myqandatoc.mode"/>
379</xsl:template>
380
381<xsl:template match="question" mode="myqandatoc.mode">
382 <xsl:variable name="firstch" select="(*[name(.)!='label'])[1]"/>
383 <xsl:variable name="deflabel">
384 <xsl:choose>
385 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
386 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
387 /@defaultlabel"/>
388 </xsl:when>
389 <xsl:otherwise>
390 <xsl:value-of select="$qanda.defaultlabel"/>
391 </xsl:otherwise>
392 </xsl:choose>
393 </xsl:variable>
394 <xsl:apply-templates select="." mode="label.markup"/>
395 <xsl:if test="$deflabel = 'number' and not(label)">
396 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
397 </xsl:if>
398 <xsl:text> </xsl:text>
399 <a>
400 <xsl:attribute name="href">
401 <xsl:call-template name="href.target">
402 <xsl:with-param name="object" select=".."/>
403 </xsl:call-template>
404 </xsl:attribute>
405 <xsl:value-of select="$firstch"/>
406 </a>
407 <br />
408</xsl:template>
409
410
411</xsl:stylesheet>