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"
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'"/>
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)"/>
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"/>
46 <xsl:apply-templates select=
"$preamble"/>
47 <xsl:call-template name=
"process.qandaset"/>
51 <xsl:template match=
"qandaset/blockinfo/title|
54 <xsl:variable name=
"qalevel">
55 <xsl:call-template name=
"qanda.section.level"/>
57 <xsl:element name=
"h{string(number($qalevel)+1)}">
58 <xsl:attribute name=
"class">
59 <xsl:value-of select=
"local-name(.)"/>
61 <xsl:call-template name=
"anchor">
62 <xsl:with-param name=
"node" select=
".."/>
63 <xsl:with-param name=
"conditional" select=
"0"/>
65 <xsl:apply-templates/>
69 <xsl:template match=
"qandaset/blockinfo|qandaset/info">
70 <!-- what should this template really do? -->
71 <xsl:apply-templates select=
"legalnotice" mode=
"titlepage.mode"/>
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">
82 <td align=
"left" valign=
"top" colspan=
"2">
83 <xsl:apply-templates select=
"(blockinfo/title|info/title|title)[1]"/>
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'"/>
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)"/>
102 <xsl:if test=
"(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
104 <td align=
"left" valign=
"top" colspan=
"2">
105 <xsl:call-template name=
"process.qanda.toc"/>
109 <xsl:if test=
"$preamble">
111 <td align=
"left" valign=
"top" colspan=
"2">
112 <xsl:apply-templates select=
"$preamble"/>
116 <xsl:apply-templates select=
"qandadiv|qandaentry"/>
119 <xsl:template match=
"qandadiv/blockinfo/title|
122 <xsl:variable name=
"qalevel">
123 <xsl:call-template name=
"qandadiv.section.level"/>
126 <xsl:element name=
"h{string(number($qalevel)+1)}">
127 <xsl:attribute name=
"class">
128 <xsl:value-of select=
"local-name(.)"/>
130 <xsl:call-template name=
"anchor">
131 <xsl:with-param name=
"node" select=
".."/>
132 <xsl:with-param name=
"conditional" select=
"0"/>
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>
139 <xsl:apply-templates/>
143 <xsl:template match=
"qandaentry">
144 <xsl:apply-templates/>
147 <xsl:template match=
"question">
148 <xsl:variable name=
"deflabel">
150 <xsl:when test=
"ancestor-or-self::*[@defaultlabel]">
151 <xsl:value-of select=
"(ancestor-or-self::*[@defaultlabel])[last()]
155 <xsl:value-of select=
"$qanda.defaultlabel"/>
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"/>
167 <xsl:call-template name=
"anchor">
168 <xsl:with-param name=
"conditional" select=
"0"/>
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"/>
178 <xsl:if test=
"string-length($label.content) > 0">
180 <xsl:copy-of select=
"$label.content"/>
184 <td align=
"left" valign=
"top">
186 <xsl:when test=
"$deflabel = 'none' and not(label)">
187 <b><xsl:apply-templates select=
"*[local-name(.) != 'label']"/></b>
190 <xsl:apply-templates select=
"*[local-name(.) != 'label']"/>
197 <xsl:template match=
"answer">
198 <xsl:variable name=
"deflabel">
200 <xsl:when test=
"ancestor-or-self::*[@defaultlabel]">
201 <xsl:value-of select=
"(ancestor-or-self::*[@defaultlabel])[last()]
205 <xsl:value-of select=
"$qanda.defaultlabel"/>
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"/>
216 <xsl:if test=
"string-length($answer.label) > 0">
218 <xsl:copy-of select=
"$answer.label"/>
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"/>
234 <xsl:template match=
"label">
235 <xsl:apply-templates/>
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 -->
244 <xsl:apply-templates select=
"qandadiv" mode=
"qandatoc.mode"/>
245 <xsl:apply-templates select=
"qandaset|qandaentry" mode=
"qandatoc.mode"/>
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>
254 <xsl:template match=
"qandadiv/blockinfo/title|
256 qandadiv/title" mode=
"qandatoc.mode">
257 <xsl:variable name=
"qalevel">
258 <xsl:call-template name=
"qandadiv.section.level"/>
260 <xsl:variable name=
"id">
261 <xsl:call-template name=
"object.id">
262 <xsl:with-param name=
"object" select=
"parent::*"/>
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::*"/>
275 <xsl:apply-templates/>
279 <xsl:template match=
"qandaset" mode=
"qandatoc.mode">
280 <xsl:for-each select=
"qandaentry">
281 <xsl:apply-templates select=
"." mode=
"qandatoc.mode"/>
285 <xsl:template match=
"qandaentry" mode=
"qandatoc.mode">
286 <xsl:apply-templates select=
"question" mode=
"qandatoc.mode"/>
289 <xsl:template match=
"question" mode=
"qandatoc.mode">
290 <xsl:variable name=
"firstch">
291 <xsl:apply-templates select=
"(*[local-name(.)!='label'])[1]"/>
293 <xsl:variable name=
"deflabel">
295 <xsl:when test=
"ancestor-or-self::*[@defaultlabel]">
296 <xsl:value-of select=
"(ancestor-or-self::*[@defaultlabel])[last()]
300 <xsl:value-of select=
"$qanda.defaultlabel"/>
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"/>
310 <xsl:text> </xsl:text>
312 <xsl:attribute name=
"href">
313 <xsl:call-template name=
"href.target">
314 <xsl:with-param name=
"object" select=
".."/>
317 <xsl:value-of select=
"$firstch"/>
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"/>
326 <xsl:template match=
"answer" mode=
"qandatoc.mode">
327 <xsl:if test=
"descendant::question">
329 <xsl:call-template name=
"process.qanda.toc"/>
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'"/>
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'"/>
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'"/>
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'"/>
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"/>
377 <xsl:if test=
"$cellpadding != ''">
378 <xsl:attribute name=
"cellpadding">
379 <xsl:value-of select=
"$cellpadding"/>
383 <xsl:if test=
"$cellspacing != ''">
384 <xsl:attribute name=
"cellspacing">
385 <xsl:value-of select=
"$cellspacing"/>
390 <xsl:attribute name=
"width">
392 <xsl:when test=
"$label-width != ''">
393 <xsl:value-of select=
"$label-width"/>
395 <xsl:otherwise>1%
</xsl:otherwise>
400 <xsl:apply-templates select=
"qandaentry|qandadiv"/>
405 <!-- ==================================================================== -->
407 <xsl:template match=
"*" mode=
"no.wrapper.mode">
408 <xsl:apply-templates/>
411 <!-- ==================================================================== -->