source: clfs-embedded/BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/xhtml/qandaset.xsl @ 9882b55

Last change on this file since 9882b55 was 9882b55, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added the new lfs-xsl stylesheets.

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