source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/html/qandaset.xsl@ 15c7d39

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 15c7d39 was 15c7d39, checked in by Matthew Burgess <matthew@…>, 11 years ago

Update stylesheets to docbook-xsl-1.78.1.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 15.3 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4 exclude-result-prefixes="doc"
5 version='1.0'>
6
7<!-- ********************************************************************
8 $Id: qandaset.xsl 9354 2012-05-12 23:29:36Z bobstayton $
9 ********************************************************************
10
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://docbook.sf.net/release/xsl/current/ for
13 copyright and other information.
14
15 ******************************************************************** -->
16
17<!-- ==================================================================== -->
18
19<xsl:template match="qandaset">
20 <xsl:variable name="title" select="(blockinfo/title|info/title|title)[1]"/>
21 <xsl:variable name="preamble" select="*[local-name(.) != 'title'
22 and local-name(.) != 'titleabbrev'
23 and local-name(.) != 'qandadiv'
24 and local-name(.) != 'qandaentry']"/>
25 <xsl:variable name="toc">
26 <xsl:call-template name="pi.dbhtml_toc"/>
27 </xsl:variable>
28
29 <xsl:variable name="toc.params">
30 <xsl:call-template name="find.path.params">
31 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
32 </xsl:call-template>
33 </xsl:variable>
34
35 <div>
36 <xsl:apply-templates select="." mode="common.html.attributes"/>
37 <xsl:call-template name="id.attribute">
38 <xsl:with-param name="conditional" select="0"/>
39 </xsl:call-template>
40 <xsl:apply-templates select="$title"/>
41 <xsl:if test="not($title)">
42 <!-- andhor is output on title if there is one -->
43 <xsl:call-template name="anchor">
44 <xsl:with-param name="conditional" select="0"/>
45 </xsl:call-template>
46 </xsl:if>
47 <xsl:if test="((contains($toc.params, 'toc') and $toc != '0') or $toc = '1')
48 and not(ancestor::answer and not($qanda.nested.in.toc=0))">
49 <xsl:call-template name="process.qanda.toc"/>
50 </xsl:if>
51 <xsl:apply-templates select="$preamble"/>
52 <xsl:call-template name="process.qandaset"/>
53 </div>
54</xsl:template>
55
56<xsl:template match="qandaset/blockinfo/title|
57 qandaset/info/title|
58 qandaset/title">
59 <xsl:variable name="qalevel">
60 <xsl:call-template name="qanda.section.level"/>
61 </xsl:variable>
62 <xsl:element name="h{string(number($qalevel)+1)}">
63 <xsl:apply-templates select="." mode="class.attribute"/>
64 <xsl:call-template name="anchor">
65 <xsl:with-param name="node" select=".."/>
66 <xsl:with-param name="conditional" select="0"/>
67 </xsl:call-template>
68 <xsl:apply-templates/>
69 </xsl:element>
70</xsl:template>
71
72<xsl:template match="qandaset/blockinfo|qandaset/info">
73 <!-- what should this template really do? -->
74 <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
75</xsl:template>
76
77<xsl:template match="qandadiv">
78 <xsl:variable name="preamble" select="*[local-name(.) != 'title'
79 and local-name(.) != 'titleabbrev'
80 and local-name(.) != 'qandadiv'
81 and local-name(.) != 'qandaentry']"/>
82
83 <xsl:if test="blockinfo/title|info/title|title">
84 <tr class="qandadiv">
85 <td align="{$direction.align.start}" valign="top" colspan="2">
86 <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
87 </td>
88 </tr>
89 </xsl:if>
90
91 <xsl:variable name="toc">
92 <xsl:call-template name="pi.dbhtml_toc"/>
93 </xsl:variable>
94
95 <xsl:variable name="toc.params">
96 <xsl:call-template name="find.path.params">
97 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
98 </xsl:call-template>
99 </xsl:variable>
100
101 <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
102 <tr class="toc">
103 <td align="{$direction.align.start}" valign="top" colspan="2">
104 <xsl:call-template name="process.qanda.toc"/>
105 </td>
106 </tr>
107 </xsl:if>
108 <xsl:if test="$preamble">
109 <tr class="toc">
110 <td align="{$direction.align.start}" valign="top" colspan="2">
111 <xsl:apply-templates select="$preamble"/>
112 </td>
113 </tr>
114 </xsl:if>
115 <xsl:apply-templates select="qandadiv|qandaentry"/>
116</xsl:template>
117
118<xsl:template match="qandadiv/blockinfo/title|
119 qandadiv/info/title|
120 qandadiv/title">
121 <xsl:variable name="qalevel">
122 <xsl:call-template name="qandadiv.section.level"/>
123 </xsl:variable>
124
125 <xsl:element name="h{string(number($qalevel)+1)}">
126 <xsl:apply-templates select="." mode="class.attribute"/>
127 <xsl:call-template name="id.attribute">
128 <xsl:with-param name="node" select=".."/>
129 <xsl:with-param name="conditional" select="0"/>
130 </xsl:call-template>
131 <xsl:call-template name="anchor">
132 <xsl:with-param name="node" select=".."/>
133 <xsl:with-param name="conditional" select="0"/>
134 </xsl:call-template>
135 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
136 <xsl:if test="$qandadiv.autolabel != 0">
137 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
138 <xsl:text> </xsl:text>
139 </xsl:if>
140 <xsl:apply-templates/>
141 </xsl:element>
142</xsl:template>
143
144<xsl:template match="qandaentry">
145 <xsl:apply-templates/>
146</xsl:template>
147
148<xsl:template match="question">
149 <xsl:variable name="deflabel">
150 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
151 </xsl:variable>
152
153 <tr>
154 <xsl:apply-templates select="." mode="common.html.attributes"/>
155 <!-- capture the id of the quandaentry -->
156 <xsl:call-template name="id.attribute">
157 <xsl:with-param name="node" select=".."/>
158 <xsl:with-param name="conditional" select="0"/>
159 </xsl:call-template>
160 <td align="{$direction.align.start}" valign="top">
161 <!-- and the id of the question too -->
162 <xsl:call-template name="id.attribute">
163 <xsl:with-param name="conditional" select="0"/>
164 </xsl:call-template>
165 <xsl:call-template name="anchor">
166 <xsl:with-param name="node" select=".."/>
167 <xsl:with-param name="conditional" select="0"/>
168 </xsl:call-template>
169 <xsl:call-template name="anchor">
170 <xsl:with-param name="conditional" select="0"/>
171 </xsl:call-template>
172
173 <xsl:variable name="label.content">
174 <xsl:apply-templates select="." mode="qanda.label"/>
175 </xsl:variable>
176
177 <xsl:if test="string-length($label.content) &gt; 0">
178 <p><b>
179 <xsl:copy-of select="$label.content"/>
180 </b></p>
181 </xsl:if>
182 </td>
183 <td align="{$direction.align.start}" valign="top">
184 <xsl:choose>
185 <xsl:when test="$deflabel = 'none' and not(label)">
186 <b><xsl:apply-templates select="*[local-name(.) != 'label']"/></b>
187 </xsl:when>
188 <xsl:otherwise>
189 <xsl:apply-templates select="*[local-name(.) != 'label']"/>
190 </xsl:otherwise>
191 </xsl:choose>
192 </td>
193 </tr>
194</xsl:template>
195
196<xsl:template match="*" mode="qanda.defaultlabel">
197 <xsl:choose>
198 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
199 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
200 /@defaultlabel"/>
201 </xsl:when>
202 <xsl:otherwise>
203 <xsl:value-of select="$qanda.defaultlabel"/>
204 </xsl:otherwise>
205 </xsl:choose>
206</xsl:template>
207
208<xsl:template match="question" mode="qanda.label">
209 <xsl:variable name="deflabel">
210 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
211 </xsl:variable>
212 <xsl:apply-templates select="." mode="label.markup"/>
213 <xsl:if test="contains($deflabel, 'number') and not(label)">
214 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
215 </xsl:if>
216</xsl:template>
217
218<xsl:template match="answer">
219 <xsl:variable name="deflabel">
220 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
221 </xsl:variable>
222
223 <tr>
224 <xsl:apply-templates select="." mode="common.html.attributes"/>
225 <xsl:call-template name="id.attribute"/>
226 <td align="{$direction.align.start}" valign="top">
227 <xsl:call-template name="anchor"/>
228 <xsl:variable name="answer.label">
229 <xsl:apply-templates select="." mode="label.markup"/>
230 </xsl:variable>
231 <xsl:if test="string-length($answer.label) &gt; 0">
232 <p><b>
233 <xsl:copy-of select="$answer.label"/>
234 </b></p>
235 </xsl:if>
236 </td>
237 <td align="{$direction.align.start}" valign="top">
238 <xsl:apply-templates select="*[local-name(.) != 'label'
239 and local-name(.) != 'qandaentry']"/>
240 <!-- * handle nested answer/qandaentry instances -->
241 <!-- * (bug 1509043 from Daniel Leidert) -->
242 <xsl:if test="descendant::question">
243 <xsl:call-template name="process.qandaset"/>
244 </xsl:if>
245 </td>
246 </tr>
247</xsl:template>
248
249<xsl:template match="answer" mode="qanda.label">
250 <xsl:apply-templates select="." mode="label.markup"/>
251</xsl:template>
252
253<xsl:template match="label">
254 <xsl:apply-templates/>
255</xsl:template>
256
257<!-- ==================================================================== -->
258
259<xsl:template name="process.qanda.toc">
260 <!-- * if user wants nested qandaset and qandaentry in main Qandaset TOC, -->
261 <!-- * then don't also include the nested stuff in the sub TOCs -->
262 <dl>
263 <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
264 <xsl:apply-templates select="qandaset|qandaentry" mode="qandatoc.mode"/>
265 </dl>
266</xsl:template>
267
268<xsl:template match="qandadiv" mode="qandatoc.mode">
269 <dt><xsl:apply-templates select="title" mode="qandatoc.mode"/></dt>
270 <dd><xsl:call-template name="process.qanda.toc"/></dd>
271</xsl:template>
272
273<xsl:template match="qandadiv/blockinfo/title|
274 qandadiv/info/title|
275 qandadiv/title" mode="qandatoc.mode">
276 <xsl:variable name="qalevel">
277 <xsl:call-template name="qandadiv.section.level"/>
278 </xsl:variable>
279 <xsl:variable name="id">
280 <xsl:call-template name="object.id">
281 <xsl:with-param name="object" select="parent::*"/>
282 </xsl:call-template>
283 </xsl:variable>
284
285 <xsl:variable name="div.label">
286 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
287 </xsl:variable>
288 <xsl:if test="string-length($div.label) != 0">
289 <xsl:copy-of select="$div.label"/>
290 <xsl:value-of select="$autotoc.label.separator"/>
291 </xsl:if>
292 <xsl:text> </xsl:text>
293 <a>
294 <xsl:attribute name="href">
295 <xsl:call-template name="href.target">
296 <xsl:with-param name="object" select="parent::*"/>
297 </xsl:call-template>
298 </xsl:attribute>
299 <xsl:apply-templates/>
300 </a>
301</xsl:template>
302
303<xsl:template match="qandaset" mode="qandatoc.mode">
304 <xsl:for-each select="qandaentry">
305 <xsl:apply-templates select="." mode="qandatoc.mode"/>
306 </xsl:for-each>
307</xsl:template>
308
309<xsl:template match="qandaentry" mode="qandatoc.mode">
310 <xsl:apply-templates select="question" mode="qandatoc.mode"/>
311</xsl:template>
312
313<xsl:template match="question" mode="qandatoc.mode">
314 <xsl:variable name="firstch">
315 <!-- Use a titleabbrev or title if available -->
316 <xsl:choose>
317 <xsl:when test="../blockinfo/titleabbrev">
318 <xsl:apply-templates select="../blockinfo/titleabbrev[1]/node()"/>
319 </xsl:when>
320 <xsl:when test="../blockinfo/title">
321 <xsl:apply-templates select="../blockinfo/title[1]/node()"/>
322 </xsl:when>
323 <xsl:when test="../info/titleabbrev">
324 <xsl:apply-templates select="../info/titleabbrev[1]/node()"/>
325 </xsl:when>
326 <xsl:when test="../titleabbrev">
327 <xsl:apply-templates select="../titleabbrev[1]/node()"/>
328 </xsl:when>
329 <xsl:when test="../info/title">
330 <xsl:apply-templates select="../info/title[1]/node()"/>
331 </xsl:when>
332 <xsl:when test="../title">
333 <xsl:apply-templates select="../title[1]/node()"/>
334 </xsl:when>
335 <xsl:otherwise>
336 <xsl:apply-templates select="(*[local-name(.)!='label'])[1]/node()"/>
337 </xsl:otherwise>
338 </xsl:choose>
339 </xsl:variable>
340 <xsl:variable name="deflabel">
341 <xsl:choose>
342 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
343 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
344 /@defaultlabel"/>
345 </xsl:when>
346 <xsl:otherwise>
347 <xsl:value-of select="$qanda.defaultlabel"/>
348 </xsl:otherwise>
349 </xsl:choose>
350 </xsl:variable>
351
352 <dt>
353 <xsl:apply-templates select="." mode="label.markup"/>
354 <xsl:if test="contains($deflabel,'number') and not(label)">
355 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
356 </xsl:if>
357 <xsl:text> </xsl:text>
358 <a>
359 <xsl:attribute name="href">
360 <xsl:call-template name="href.target">
361 <xsl:with-param name="object" select=".."/>
362 </xsl:call-template>
363 </xsl:attribute>
364 <xsl:value-of select="$firstch"/>
365 </a>
366 </dt>
367 <!-- * include nested qandaset/qandaentry in TOC if user wants it -->
368 <xsl:if test="not($qanda.nested.in.toc = 0)">
369 <xsl:apply-templates select="following-sibling::answer" mode="qandatoc.mode"/>
370 </xsl:if>
371</xsl:template>
372
373<xsl:template match="answer" mode="qandatoc.mode">
374 <xsl:if test="descendant::question">
375 <dd>
376 <xsl:call-template name="process.qanda.toc"/>
377 </dd>
378 </xsl:if>
379</xsl:template>
380
381<!-- ==================================================================== -->
382
383<xsl:template name="process.qandaset">
384
385 <xsl:variable name="deflabel">
386 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
387 </xsl:variable>
388
389 <xsl:variable name="label-width">
390 <xsl:call-template name="pi.dbhtml_label-width"/>
391 </xsl:variable>
392
393 <xsl:variable name="table-summary">
394 <xsl:call-template name="pi.dbhtml_table-summary"/>
395 </xsl:variable>
396
397 <xsl:variable name="cellpadding">
398 <xsl:call-template name="pi.dbhtml_cellpadding"/>
399 </xsl:variable>
400
401 <xsl:variable name="cellspacing">
402 <xsl:call-template name="pi.dbhtml_cellspacing"/>
403 </xsl:variable>
404
405 <table border="{$table.border.off}">
406 <xsl:if test="$css.decoration != 0">
407 <xsl:attribute name="style">width: 100%;</xsl:attribute>
408 </xsl:if>
409 <xsl:if test="$table-summary != ''">
410 <xsl:attribute name="summary">
411 <xsl:value-of select="$table-summary"/>
412 </xsl:attribute>
413 </xsl:if>
414
415 <xsl:if test="$cellpadding != ''">
416 <xsl:attribute name="cellpadding">
417 <xsl:value-of select="$cellpadding"/>
418 </xsl:attribute>
419 </xsl:if>
420
421 <xsl:if test="$cellspacing != ''">
422 <xsl:attribute name="cellspacing">
423 <xsl:value-of select="$cellspacing"/>
424 </xsl:attribute>
425 </xsl:if>
426
427 <colgroup>
428 <col align="{$direction.align.start}">
429 <xsl:attribute name="width">
430 <xsl:choose>
431 <xsl:when test="$label-width != ''">
432 <xsl:value-of select="$label-width"/>
433 </xsl:when>
434 <xsl:otherwise>
435 <xsl:text>1%</xsl:text>
436 </xsl:otherwise>
437 </xsl:choose>
438 </xsl:attribute>
439 </col>
440 <col/>
441 </colgroup>
442 <tbody>
443 <xsl:apply-templates select="qandaentry|qandadiv"/>
444 </tbody>
445 </table>
446</xsl:template>
447
448<!-- ==================================================================== -->
449
450<xsl:template match="*" mode="no.wrapper.mode">
451 <xsl:apply-templates/>
452</xsl:template>
453
454<!-- ==================================================================== -->
455
456</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.