source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/xhtml/qandaset.xsl@ 89306f9

clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 89306f9 was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

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