Project

General

Profile

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 8421 2009-05-04 07:49:49Z 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:apply-templates select="$title"/>
38
    <xsl:if test="not($title)">
39
      <!-- id is output on title if there is one -->
40
      <xsl:call-template name="anchor">
41
        <xsl:with-param name="conditional" select="0"/>
42
      </xsl:call-template>
43
    </xsl:if>
44
    <xsl:if test="((contains($toc.params, 'toc') and $toc != '0') or $toc = '1')
45
                  and not(ancestor::answer and not($qanda.nested.in.toc=0))">
46
      <xsl:call-template name="process.qanda.toc"/>
47
    </xsl:if>
48
    <xsl:apply-templates select="$preamble"/>
49
    <xsl:call-template name="process.qandaset"/>
50
  </div>
51
</xsl:template>
52

    
53
<xsl:template match="qandaset/blockinfo/title|
54
                     qandaset/info/title|
55
                     qandaset/title">
56
  <xsl:variable name="qalevel">
57
    <xsl:call-template name="qanda.section.level"/>
58
  </xsl:variable>
59
  <xsl:element name="h{string(number($qalevel)+1)}">
60
    <xsl:attribute name="class">
61
      <xsl:value-of select="local-name(.)"/>
62
    </xsl:attribute>
63
    <xsl:call-template name="anchor">
64
      <xsl:with-param name="node" select=".."/>
65
      <xsl:with-param name="conditional" select="0"/>
66
    </xsl:call-template>
67
    <xsl:apply-templates/>
68
  </xsl:element>
69
</xsl:template>
70

    
71
<xsl:template match="qandaset/blockinfo|qandaset/info">
72
  <!-- what should this template really do? -->
73
  <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
74
</xsl:template>
75

    
76
<xsl:template match="qandadiv">
77
  <xsl:variable name="preamble" select="*[local-name(.) != 'title'
78
                                          and local-name(.) != 'titleabbrev'
79
                                          and local-name(.) != 'qandadiv'
80
                                          and local-name(.) != 'qandaentry']"/>
81

    
82
  <xsl:if test="blockinfo/title|info/title|title">
83
    <tr class="qandadiv">
84
      <td align="{$direction.align.start}" valign="top" colspan="2">
85
        <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
86
      </td>
87
    </tr>
88
  </xsl:if>
89

    
90
  <xsl:variable name="toc">
91
    <xsl:call-template name="pi.dbhtml_toc"/>
92
  </xsl:variable>
93

    
94
  <xsl:variable name="toc.params">
95
    <xsl:call-template name="find.path.params">
96
      <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
97
    </xsl:call-template>
98
  </xsl:variable>
99

    
100
  <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
101
    <tr class="toc">
102
      <td align="{$direction.align.start}" valign="top" colspan="2">
103
        <xsl:call-template name="process.qanda.toc"/>
104
      </td>
105
    </tr>
106
  </xsl:if>
107
  <xsl:if test="$preamble">
108
    <tr class="toc">
109
      <td align="{$direction.align.start}" valign="top" colspan="2">
110
        <xsl:apply-templates select="$preamble"/>
111
      </td>
112
    </tr>
113
  </xsl:if>
114
  <xsl:apply-templates select="qandadiv|qandaentry"/>
115
</xsl:template>
116

    
117
<xsl:template match="qandadiv/blockinfo/title|
118
                     qandadiv/info/title|
119
                     qandadiv/title">
120
  <xsl:variable name="qalevel">
121
    <xsl:call-template name="qandadiv.section.level"/>
122
  </xsl:variable>
123

    
124
  <xsl:element name="h{string(number($qalevel)+1)}">
125
    <xsl:attribute name="class">
126
      <xsl:value-of select="local-name(.)"/>
127
    </xsl:attribute>
128
    <xsl:call-template name="anchor">
129
      <xsl:with-param name="node" select=".."/>
130
      <xsl:with-param name="conditional" select="0"/>
131
    </xsl:call-template>
132
    <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
133
    <xsl:if test="$qandadiv.autolabel != 0">
134
      <xsl:apply-templates select="." mode="intralabel.punctuation"/>
135
      <xsl:text> </xsl:text>
136
    </xsl:if>
137
    <xsl:apply-templates/>
138
  </xsl:element>
139
</xsl:template>
140

    
141
<xsl:template match="qandaentry">
142
  <xsl:apply-templates/>
143
</xsl:template>
144

    
145
<xsl:template match="question">
146
  <xsl:variable name="deflabel">
147
    <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
148
  </xsl:variable>
149

    
150
  <tr>
151
    <xsl:apply-templates select="." mode="common.html.attributes"/>
152
    <td align="{$direction.align.start}" valign="top">
153
      <xsl:call-template name="anchor">
154
        <xsl:with-param name="node" select=".."/>
155
        <xsl:with-param name="conditional" select="0"/>
156
      </xsl:call-template>
157
      <xsl:call-template name="anchor">
158
        <xsl:with-param name="conditional" select="0"/>
159
      </xsl:call-template>
160

    
161
      <xsl:variable name="label.content">
162
        <xsl:apply-templates select="." mode="qanda.label"/>
163
      </xsl:variable>
164

    
165
      <xsl:if test="string-length($label.content) &gt; 0">
166
        <p><b>
167
          <xsl:copy-of select="$label.content"/>
168
        </b></p>
169
      </xsl:if>
170
    </td>
171
    <td align="{$direction.align.start}" valign="top">
172
      <xsl:choose>
173
        <xsl:when test="$deflabel = 'none' and not(label)">
174
          <b><xsl:apply-templates select="*[local-name(.) != 'label']"/></b>
175
        </xsl:when>
176
        <xsl:otherwise>
177
          <xsl:apply-templates select="*[local-name(.) != 'label']"/>
178
        </xsl:otherwise>
179
      </xsl:choose>
180
    </td>
181
  </tr>
182
</xsl:template>
183

    
184
<xsl:template match="*" mode="qanda.defaultlabel">
185
  <xsl:choose>
186
    <xsl:when test="ancestor-or-self::*[@defaultlabel]">
187
      <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
188
                            /@defaultlabel"/>
189
    </xsl:when>
190
    <xsl:otherwise>
191
      <xsl:value-of select="$qanda.defaultlabel"/>
192
    </xsl:otherwise>
193
  </xsl:choose>
194
</xsl:template>
195

    
196
<xsl:template match="question" mode="qanda.label">
197
  <xsl:variable name="deflabel">
198
    <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
199
  </xsl:variable>
200
  <xsl:apply-templates select="." mode="label.markup"/>
201
  <xsl:if test="contains($deflabel, 'number') and not(label)">
202
    <xsl:apply-templates select="." mode="intralabel.punctuation"/>
203
  </xsl:if>
204
</xsl:template>
205

    
206
<xsl:template match="answer">
207
  <xsl:variable name="deflabel">
208
    <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
209
  </xsl:variable>
210

    
211
  <tr class="{local-name(.)}">
212
    <td align="{$direction.align.start}" valign="top">
213
      <xsl:call-template name="anchor"/>
214
      <xsl:variable name="answer.label">
215
        <xsl:apply-templates select="." mode="label.markup"/>
216
      </xsl:variable>
217
      <xsl:if test="string-length($answer.label) &gt; 0">
218
        <p><b>
219
          <xsl:copy-of select="$answer.label"/>
220
        </b></p>
221
      </xsl:if>
222
    </td>
223
    <td align="{$direction.align.start}" valign="top">
224
      <xsl:apply-templates select="*[local-name(.) != 'label'
225
        and local-name(.) != 'qandaentry']"/>
226
      <!-- * handle nested answer/qandaentry instances -->
227
      <!-- * (bug 1509043 from Daniel Leidert) -->
228
      <xsl:if test="descendant::question">
229
        <xsl:call-template name="process.qandaset"/>
230
      </xsl:if>
231
    </td>
232
  </tr>
233
</xsl:template>
234

    
235
<xsl:template match="answer" mode="qanda.label">
236
  <xsl:apply-templates select="." mode="label.markup"/>
237
</xsl:template>
238

    
239
<xsl:template match="label">
240
  <xsl:apply-templates/>
241
</xsl:template>
242

    
243
<!-- ==================================================================== -->
244

    
245
<xsl:template name="process.qanda.toc">
246
  <!-- * if user wants nested qandaset and qandaentry in main Qandaset TOC, -->
247
  <!-- * then don't also include the nested stuff in the sub TOCs -->
248
  <dl>
249
    <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
250
    <xsl:apply-templates select="qandaset|qandaentry" mode="qandatoc.mode"/>
251
  </dl>
252
</xsl:template>
253

    
254
<xsl:template match="qandadiv" mode="qandatoc.mode">
255
  <dt><xsl:apply-templates select="title" mode="qandatoc.mode"/></dt>
256
  <dd><xsl:call-template name="process.qanda.toc"/></dd>
257
</xsl:template>
258

    
259
<xsl:template match="qandadiv/blockinfo/title|
260
                     qandadiv/info/title|
261
                     qandadiv/title" mode="qandatoc.mode">
262
  <xsl:variable name="qalevel">
263
    <xsl:call-template name="qandadiv.section.level"/>
264
  </xsl:variable>
265
  <xsl:variable name="id">
266
    <xsl:call-template name="object.id">
267
      <xsl:with-param name="object" select="parent::*"/>
268
    </xsl:call-template>
269
  </xsl:variable>
270

    
271
  <xsl:variable name="div.label">
272
    <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
273
  </xsl:variable>
274
  <xsl:if test="string-length($div.label) != 0">
275
    <xsl:copy-of select="$div.label"/>
276
    <xsl:value-of select="$autotoc.label.separator"/>
277
  </xsl:if>
278
  <xsl:text> </xsl:text>
279
  <a>
280
    <xsl:attribute name="href">
281
      <xsl:call-template name="href.target">
282
        <xsl:with-param name="object" select="parent::*"/>
283
      </xsl:call-template>
284
    </xsl:attribute>
285
    <xsl:apply-templates/>
286
  </a>
287
</xsl:template>
288

    
289
<xsl:template match="qandaset" mode="qandatoc.mode">
290
  <xsl:for-each select="qandaentry">
291
    <xsl:apply-templates select="." mode="qandatoc.mode"/>
292
  </xsl:for-each>
293
</xsl:template>
294

    
295
<xsl:template match="qandaentry" mode="qandatoc.mode">
296
  <xsl:apply-templates select="question" mode="qandatoc.mode"/>
297
</xsl:template>
298

    
299
<xsl:template match="question" mode="qandatoc.mode">
300
  <xsl:variable name="firstch">
301
    <!-- Use a titleabbrev or title if available -->
302
    <xsl:choose>
303
      <xsl:when test="../blockinfo/titleabbrev">
304
        <xsl:apply-templates select="../blockinfo/titleabbrev[1]/node()"/>
305
      </xsl:when>
306
      <xsl:when test="../blockinfo/title">
307
        <xsl:apply-templates select="../blockinfo/title[1]/node()"/>
308
      </xsl:when>
309
      <xsl:when test="../info/titleabbrev">
310
        <xsl:apply-templates select="../info/titleabbrev[1]/node()"/>
311
      </xsl:when>
312
      <xsl:when test="../titleabbrev">
313
        <xsl:apply-templates select="../titleabbrev[1]/node()"/>
314
      </xsl:when>
315
      <xsl:when test="../info/title">
316
        <xsl:apply-templates select="../info/title[1]/node()"/>
317
      </xsl:when>
318
      <xsl:when test="../title">
319
        <xsl:apply-templates select="../title[1]/node()"/>
320
      </xsl:when>
321
      <xsl:otherwise>
322
        <xsl:apply-templates select="(*[local-name(.)!='label'])[1]/node()"/>
323
      </xsl:otherwise>
324
    </xsl:choose>
325
  </xsl:variable>
326
  <xsl:variable name="deflabel">
327
    <xsl:choose>
328
      <xsl:when test="ancestor-or-self::*[@defaultlabel]">
329
        <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
330
                              /@defaultlabel"/>
331
      </xsl:when>
332
      <xsl:otherwise>
333
        <xsl:value-of select="$qanda.defaultlabel"/>
334
      </xsl:otherwise>
335
    </xsl:choose>
336
  </xsl:variable>
337

    
338
  <dt>
339
    <xsl:apply-templates select="." mode="label.markup"/>
340
    <xsl:if test="contains($deflabel,'number') and not(label)">
341
      <xsl:apply-templates select="." mode="intralabel.punctuation"/>
342
    </xsl:if>
343
    <xsl:text> </xsl:text>
344
    <a>
345
      <xsl:attribute name="href">
346
        <xsl:call-template name="href.target">
347
          <xsl:with-param name="object" select=".."/>
348
        </xsl:call-template>
349
      </xsl:attribute>
350
      <xsl:value-of select="$firstch"/>
351
    </a>
352
  </dt>
353
  <!-- * include nested qandaset/qandaentry in TOC if user wants it -->
354
  <xsl:if test="not($qanda.nested.in.toc = 0)">
355
    <xsl:apply-templates select="following-sibling::answer" mode="qandatoc.mode"/>
356
  </xsl:if>
357
</xsl:template>
358

    
359
<xsl:template match="answer" mode="qandatoc.mode">
360
  <xsl:if test="descendant::question">
361
    <dd>
362
      <xsl:call-template name="process.qanda.toc"/>
363
    </dd>
364
  </xsl:if>
365
</xsl:template>
366

    
367
<!-- ==================================================================== -->
368

    
369
<xsl:template name="process.qandaset">
370

    
371
  <xsl:variable name="deflabel">
372
    <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
373
  </xsl:variable>
374

    
375
  <xsl:variable name="label-width">
376
    <xsl:call-template name="pi.dbhtml_label-width"/>
377
  </xsl:variable>
378

    
379
  <xsl:variable name="table-summary">
380
    <xsl:call-template name="pi.dbhtml_table-summary"/>
381
  </xsl:variable>
382

    
383
  <xsl:variable name="cellpadding">
384
    <xsl:call-template name="pi.dbhtml_cellpadding"/>
385
  </xsl:variable>
386

    
387
  <xsl:variable name="cellspacing">
388
    <xsl:call-template name="pi.dbhtml_cellspacing"/>
389
  </xsl:variable>
390

    
391
  <table border="0" width="100%" summary="Q and A Set">
392
    <xsl:if test="$table-summary != ''">
393
      <xsl:attribute name="summary">
394
        <xsl:value-of select="$table-summary"/>
395
      </xsl:attribute>
396
    </xsl:if>
397

    
398
    <xsl:if test="$cellpadding != ''">
399
      <xsl:attribute name="cellpadding">
400
        <xsl:value-of select="$cellpadding"/>
401
      </xsl:attribute>
402
    </xsl:if>
403

    
404
    <xsl:if test="$cellspacing != ''">
405
      <xsl:attribute name="cellspacing">
406
        <xsl:value-of select="$cellspacing"/>
407
      </xsl:attribute>
408
    </xsl:if>
409

    
410
    <col align="{$direction.align.start}">
411
      <xsl:attribute name="width">
412
        <xsl:choose>
413
          <xsl:when test="$label-width != ''">
414
            <xsl:value-of select="$label-width"/>
415
          </xsl:when>
416
          <xsl:otherwise>
417
            <xsl:text>1%</xsl:text>
418
          </xsl:otherwise>
419
        </xsl:choose>
420
      </xsl:attribute>
421
    </col>
422
    <col/>
423
    <tbody>
424
      <xsl:apply-templates select="qandaentry|qandadiv"/>
425
    </tbody>
426
  </table>
427
</xsl:template>
428

    
429
<!-- ==================================================================== -->
430

    
431
<xsl:template match="*" mode="no.wrapper.mode">
432
  <xsl:apply-templates/>
433
</xsl:template>
434

    
435
<!-- ==================================================================== -->
436

    
437
</xsl:stylesheet>
(29-29/39)