Jitterbug no more.
[fvwm.git] / doc / docbook-xsl / html / qandaset.xsl
blobd42b284082d212d4bc63769b894ca1e693c9c7f8
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'>
7 <!-- ********************************************************************
8 $Id: qandaset.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
13 and other information.
15 ******************************************************************** -->
17 <!-- ==================================================================== -->
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="dbhtml-attribute">
27 <xsl:with-param name="pis"
28 select="processing-instruction('dbhtml')"/>
29 <xsl:with-param name="attribute" select="'toc'"/>
30 </xsl:call-template>
31 </xsl:variable>
33 <xsl:variable name="toc.params">
34 <xsl:call-template name="find.path.params">
35 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
36 </xsl:call-template>
37 </xsl:variable>
39 <div>
40 <xsl:apply-templates select="." mode="class.attribute"/>
41 <xsl:apply-templates select="$title"/>
42 <xsl:if test="((contains($toc.params, 'toc') and $toc != '0') or $toc = '1')
43 and not(ancestor::answer and not($qanda.nested.in.toc=0))">
44 <xsl:call-template name="process.qanda.toc"/>
45 </xsl:if>
46 <xsl:apply-templates select="$preamble"/>
47 <xsl:call-template name="process.qandaset"/>
48 </div>
49 </xsl:template>
51 <xsl:template match="qandaset/blockinfo/title|
52 qandaset/info/title|
53 qandaset/title">
54 <xsl:variable name="qalevel">
55 <xsl:call-template name="qanda.section.level"/>
56 </xsl:variable>
57 <xsl:element name="h{string(number($qalevel)+1)}">
58 <xsl:attribute name="class">
59 <xsl:value-of select="local-name(.)"/>
60 </xsl:attribute>
61 <xsl:call-template name="anchor">
62 <xsl:with-param name="node" select=".."/>
63 <xsl:with-param name="conditional" select="0"/>
64 </xsl:call-template>
65 <xsl:apply-templates/>
66 </xsl:element>
67 </xsl:template>
69 <xsl:template match="qandaset/blockinfo|qandaset/info">
70 <!-- what should this template really do? -->
71 <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
72 </xsl:template>
74 <xsl:template match="qandadiv">
75 <xsl:variable name="preamble" select="*[local-name(.) != 'title'
76 and local-name(.) != 'titleabbrev'
77 and local-name(.) != 'qandadiv'
78 and local-name(.) != 'qandaentry']"/>
80 <xsl:if test="blockinfo/title|info/title|title">
81 <tr class="qandadiv">
82 <td align="left" valign="top" colspan="2">
83 <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
84 </td>
85 </tr>
86 </xsl:if>
88 <xsl:variable name="toc">
89 <xsl:call-template name="dbhtml-attribute">
90 <xsl:with-param name="pis"
91 select="processing-instruction('dbhtml')"/>
92 <xsl:with-param name="attribute" select="'toc'"/>
93 </xsl:call-template>
94 </xsl:variable>
96 <xsl:variable name="toc.params">
97 <xsl:call-template name="find.path.params">
98 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
99 </xsl:call-template>
100 </xsl:variable>
102 <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
103 <tr class="toc">
104 <td align="left" valign="top" colspan="2">
105 <xsl:call-template name="process.qanda.toc"/>
106 </td>
107 </tr>
108 </xsl:if>
109 <xsl:if test="$preamble">
110 <tr class="toc">
111 <td align="left" valign="top" colspan="2">
112 <xsl:apply-templates select="$preamble"/>
113 </td>
114 </tr>
115 </xsl:if>
116 <xsl:apply-templates select="qandadiv|qandaentry"/>
117 </xsl:template>
119 <xsl:template match="qandadiv/blockinfo/title|
120 qandadiv/info/title|
121 qandadiv/title">
122 <xsl:variable name="qalevel">
123 <xsl:call-template name="qandadiv.section.level"/>
124 </xsl:variable>
126 <xsl:element name="h{string(number($qalevel)+1)}">
127 <xsl:attribute name="class">
128 <xsl:value-of select="local-name(.)"/>
129 </xsl:attribute>
130 <xsl:call-template name="anchor">
131 <xsl:with-param name="node" select=".."/>
132 <xsl:with-param name="conditional" select="0"/>
133 </xsl:call-template>
134 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
135 <xsl:if test="$qandadiv.autolabel != 0">
136 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
137 <xsl:text> </xsl:text>
138 </xsl:if>
139 <xsl:apply-templates/>
140 </xsl:element>
141 </xsl:template>
143 <xsl:template match="qandaentry">
144 <xsl:apply-templates/>
145 </xsl:template>
147 <xsl:template match="question">
148 <xsl:variable name="deflabel">
149 <xsl:choose>
150 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
151 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
152 /@defaultlabel"/>
153 </xsl:when>
154 <xsl:otherwise>
155 <xsl:value-of select="$qanda.defaultlabel"/>
156 </xsl:otherwise>
157 </xsl:choose>
158 </xsl:variable>
160 <tr>
161 <xsl:apply-templates select="." mode="class.attribute"/>
162 <td align="left" valign="top">
163 <xsl:call-template name="anchor">
164 <xsl:with-param name="node" select=".."/>
165 <xsl:with-param name="conditional" select="0"/>
166 </xsl:call-template>
167 <xsl:call-template name="anchor">
168 <xsl:with-param name="conditional" select="0"/>
169 </xsl:call-template>
171 <xsl:variable name="label.content">
172 <xsl:apply-templates select="." mode="label.markup"/>
173 <xsl:if test="$deflabel = 'number' and not(label)">
174 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
175 </xsl:if>
176 </xsl:variable>
178 <xsl:if test="string-length($label.content) &gt; 0">
180 <xsl:copy-of select="$label.content"/>
181 </b>
182 </xsl:if>
183 </td>
184 <td align="left" valign="top">
185 <xsl:choose>
186 <xsl:when test="$deflabel = 'none' and not(label)">
187 <b><xsl:apply-templates select="*[local-name(.) != 'label']"/></b>
188 </xsl:when>
189 <xsl:otherwise>
190 <xsl:apply-templates select="*[local-name(.) != 'label']"/>
191 </xsl:otherwise>
192 </xsl:choose>
193 </td>
194 </tr>
195 </xsl:template>
197 <xsl:template match="answer">
198 <xsl:variable name="deflabel">
199 <xsl:choose>
200 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
201 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
202 /@defaultlabel"/>
203 </xsl:when>
204 <xsl:otherwise>
205 <xsl:value-of select="$qanda.defaultlabel"/>
206 </xsl:otherwise>
207 </xsl:choose>
208 </xsl:variable>
210 <tr class="{local-name(.)}">
211 <td align="left" valign="top">
212 <xsl:call-template name="anchor"/>
213 <xsl:variable name="answer.label">
214 <xsl:apply-templates select="." mode="label.markup"/>
215 </xsl:variable>
216 <xsl:if test="string-length($answer.label) &gt; 0">
218 <xsl:copy-of select="$answer.label"/>
219 </b>
220 </xsl:if>
221 </td>
222 <td align="left" valign="top">
223 <xsl:apply-templates select="*[local-name(.) != 'label'
224 and local-name(.) != 'qandaentry']"/>
225 <!-- * handle nested answer/qandaentry instances -->
226 <!-- * (bug 1509043 from Daniel Leidert) -->
227 <xsl:if test="descendant::question">
228 <xsl:call-template name="process.qandaset"/>
229 </xsl:if>
230 </td>
231 </tr>
232 </xsl:template>
234 <xsl:template match="label">
235 <xsl:apply-templates/>
236 </xsl:template>
238 <!-- ==================================================================== -->
240 <xsl:template name="process.qanda.toc">
241 <!-- * if user wants nested qandaset and qandaentry in main Qandaset TOC, -->
242 <!-- * then don't also include the nested stuff in the sub TOCs -->
243 <dl>
244 <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
245 <xsl:apply-templates select="qandaset|qandaentry" mode="qandatoc.mode"/>
246 </dl>
247 </xsl:template>
249 <xsl:template match="qandadiv" mode="qandatoc.mode">
250 <dt><xsl:apply-templates select="title" mode="qandatoc.mode"/></dt>
251 <dd><xsl:call-template name="process.qanda.toc"/></dd>
252 </xsl:template>
254 <xsl:template match="qandadiv/blockinfo/title|
255 qandadiv/info/title|
256 qandadiv/title" mode="qandatoc.mode">
257 <xsl:variable name="qalevel">
258 <xsl:call-template name="qandadiv.section.level"/>
259 </xsl:variable>
260 <xsl:variable name="id">
261 <xsl:call-template name="object.id">
262 <xsl:with-param name="object" select="parent::*"/>
263 </xsl:call-template>
264 </xsl:variable>
266 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
267 <xsl:value-of select="$autotoc.label.separator"/>
268 <xsl:text> </xsl:text>
270 <xsl:attribute name="href">
271 <xsl:call-template name="href.target">
272 <xsl:with-param name="object" select="parent::*"/>
273 </xsl:call-template>
274 </xsl:attribute>
275 <xsl:apply-templates/>
276 </a>
277 </xsl:template>
279 <xsl:template match="qandaset" mode="qandatoc.mode">
280 <xsl:for-each select="qandaentry">
281 <xsl:apply-templates select="." mode="qandatoc.mode"/>
282 </xsl:for-each>
283 </xsl:template>
285 <xsl:template match="qandaentry" mode="qandatoc.mode">
286 <xsl:apply-templates select="question" mode="qandatoc.mode"/>
287 </xsl:template>
289 <xsl:template match="question" mode="qandatoc.mode">
290 <xsl:variable name="firstch">
291 <xsl:apply-templates select="(*[local-name(.)!='label'])[1]"/>
292 </xsl:variable>
293 <xsl:variable name="deflabel">
294 <xsl:choose>
295 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
296 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
297 /@defaultlabel"/>
298 </xsl:when>
299 <xsl:otherwise>
300 <xsl:value-of select="$qanda.defaultlabel"/>
301 </xsl:otherwise>
302 </xsl:choose>
303 </xsl:variable>
305 <dt>
306 <xsl:apply-templates select="." mode="label.markup"/>
307 <xsl:if test="$deflabel = 'number' and not(label)">
308 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
309 </xsl:if>
310 <xsl:text> </xsl:text>
312 <xsl:attribute name="href">
313 <xsl:call-template name="href.target">
314 <xsl:with-param name="object" select=".."/>
315 </xsl:call-template>
316 </xsl:attribute>
317 <xsl:value-of select="$firstch"/>
318 </a>
319 </dt>
320 <!-- * include nested qandaset/qandaentry in TOC if user wants it -->
321 <xsl:if test="not($qanda.nested.in.toc = 0)">
322 <xsl:apply-templates select="following-sibling::answer" mode="qandatoc.mode"/>
323 </xsl:if>
324 </xsl:template>
326 <xsl:template match="answer" mode="qandatoc.mode">
327 <xsl:if test="descendant::question">
328 <dd>
329 <xsl:call-template name="process.qanda.toc"/>
330 </dd>
331 </xsl:if>
332 </xsl:template>
334 <!-- ==================================================================== -->
336 <xsl:template name="process.qandaset">
338 <xsl:variable name="label-width">
339 <xsl:call-template name="dbhtml-attribute">
340 <xsl:with-param name="pis"
341 select="processing-instruction('dbhtml')"/>
342 <xsl:with-param name="attribute" select="'label-width'"/>
343 </xsl:call-template>
344 </xsl:variable>
346 <xsl:variable name="table-summary">
347 <xsl:call-template name="dbhtml-attribute">
348 <xsl:with-param name="pis"
349 select="processing-instruction('dbhtml')"/>
350 <xsl:with-param name="attribute" select="'table-summary'"/>
351 </xsl:call-template>
352 </xsl:variable>
354 <xsl:variable name="cellpadding">
355 <xsl:call-template name="dbhtml-attribute">
356 <xsl:with-param name="pis"
357 select="processing-instruction('dbhtml')"/>
358 <xsl:with-param name="attribute" select="'cellpadding'"/>
359 </xsl:call-template>
360 </xsl:variable>
362 <xsl:variable name="cellspacing">
363 <xsl:call-template name="dbhtml-attribute">
364 <xsl:with-param name="pis"
365 select="processing-instruction('dbhtml')"/>
366 <xsl:with-param name="attribute" select="'cellspacing'"/>
367 </xsl:call-template>
368 </xsl:variable>
370 <table border="0" summary="Q and A Set">
371 <xsl:if test="$table-summary != ''">
372 <xsl:attribute name="summary">
373 <xsl:value-of select="$table-summary"/>
374 </xsl:attribute>
375 </xsl:if>
377 <xsl:if test="$cellpadding != ''">
378 <xsl:attribute name="cellpadding">
379 <xsl:value-of select="$cellpadding"/>
380 </xsl:attribute>
381 </xsl:if>
383 <xsl:if test="$cellspacing != ''">
384 <xsl:attribute name="cellspacing">
385 <xsl:value-of select="$cellspacing"/>
386 </xsl:attribute>
387 </xsl:if>
389 <col align="left">
390 <xsl:attribute name="width">
391 <xsl:choose>
392 <xsl:when test="$label-width != ''">
393 <xsl:value-of select="$label-width"/>
394 </xsl:when>
395 <xsl:otherwise>1%</xsl:otherwise>
396 </xsl:choose>
397 </xsl:attribute>
398 </col>
399 <tbody>
400 <xsl:apply-templates select="qandaentry|qandadiv"/>
401 </tbody>
402 </table>
403 </xsl:template>
405 <!-- ==================================================================== -->
407 <xsl:template match="*" mode="no.wrapper.mode">
408 <xsl:apply-templates/>
409 </xsl:template>
411 <!-- ==================================================================== -->
413 </xsl:stylesheet>