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 8421 2009-05-04 07:49:49Z bobstayton $
9 ********************************************************************
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.
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="pi.dbhtml_toc"/>
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)"/>
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"/>
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"/>
48 <xsl:apply-templates select="$preamble"/>
49 <xsl:call-template name="process.qandaset"/>
53 <xsl:template match="qandaset/blockinfo/title|
56 <xsl:variable name="qalevel">
57 <xsl:call-template name="qanda.section.level"/>
59 <xsl:element name="h{string(number($qalevel)+1)}">
60 <xsl:attribute name="class">
61 <xsl:value-of select="local-name(.)"/>
63 <xsl:call-template name="anchor">
64 <xsl:with-param name="node" select=".."/>
65 <xsl:with-param name="conditional" select="0"/>
67 <xsl:apply-templates/>
71 <xsl:template match="qandaset/blockinfo|qandaset/info">
72 <!-- what should this template really do? -->
73 <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
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']"/>
82 <xsl:if test="blockinfo/title|info/title|title">
84 <td align="{$direction.align.start}" valign="top" colspan="2">
85 <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
90 <xsl:variable name="toc">
91 <xsl:call-template name="pi.dbhtml_toc"/>
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)"/>
100 <xsl:if test="(contains($toc.params, 'toc') and $toc != '0') or $toc = '1'">
102 <td align="{$direction.align.start}" valign="top" colspan="2">
103 <xsl:call-template name="process.qanda.toc"/>
107 <xsl:if test="$preamble">
109 <td align="{$direction.align.start}" valign="top" colspan="2">
110 <xsl:apply-templates select="$preamble"/>
114 <xsl:apply-templates select="qandadiv|qandaentry"/>
117 <xsl:template match="qandadiv/blockinfo/title|
120 <xsl:variable name="qalevel">
121 <xsl:call-template name="qandadiv.section.level"/>
124 <xsl:element name="h{string(number($qalevel)+1)}">
125 <xsl:attribute name="class">
126 <xsl:value-of select="local-name(.)"/>
128 <xsl:call-template name="anchor">
129 <xsl:with-param name="node" select=".."/>
130 <xsl:with-param name="conditional" select="0"/>
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>
137 <xsl:apply-templates/>
141 <xsl:template match="qandaentry">
142 <xsl:apply-templates/>
145 <xsl:template match="question">
146 <xsl:variable name="deflabel">
147 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
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"/>
157 <xsl:call-template name="anchor">
158 <xsl:with-param name="conditional" select="0"/>
161 <xsl:variable name="label.content">
162 <xsl:apply-templates select="." mode="qanda.label"/>
165 <xsl:if test="string-length($label.content) > 0">
167 <xsl:copy-of select="$label.content"/>
171 <td align="{$direction.align.start}" valign="top">
173 <xsl:when test="$deflabel = 'none' and not(label)">
174 <b><xsl:apply-templates select="*[local-name(.) != 'label']"/></b>
177 <xsl:apply-templates select="*[local-name(.) != 'label']"/>
184 <xsl:template match="*" mode="qanda.defaultlabel">
186 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
187 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
191 <xsl:value-of select="$qanda.defaultlabel"/>
196 <xsl:template match="question" mode="qanda.label">
197 <xsl:variable name="deflabel">
198 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
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"/>
206 <xsl:template match="answer">
207 <xsl:variable name="deflabel">
208 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
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"/>
217 <xsl:if test="string-length($answer.label) > 0">
219 <xsl:copy-of select="$answer.label"/>
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"/>
235 <xsl:template match="answer" mode="qanda.label">
236 <xsl:apply-templates select="." mode="label.markup"/>
239 <xsl:template match="label">
240 <xsl:apply-templates/>
243 <!-- ==================================================================== -->
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 -->
249 <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
250 <xsl:apply-templates select="qandaset|qandaentry" mode="qandatoc.mode"/>
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>
259 <xsl:template match="qandadiv/blockinfo/title|
261 qandadiv/title" mode="qandatoc.mode">
262 <xsl:variable name="qalevel">
263 <xsl:call-template name="qandadiv.section.level"/>
265 <xsl:variable name="id">
266 <xsl:call-template name="object.id">
267 <xsl:with-param name="object" select="parent::*"/>
271 <xsl:variable name="div.label">
272 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
274 <xsl:if test="string-length($div.label) != 0">
275 <xsl:copy-of select="$div.label"/>
276 <xsl:value-of select="$autotoc.label.separator"/>
278 <xsl:text> </xsl:text>
280 <xsl:attribute name="href">
281 <xsl:call-template name="href.target">
282 <xsl:with-param name="object" select="parent::*"/>
285 <xsl:apply-templates/>
289 <xsl:template match="qandaset" mode="qandatoc.mode">
290 <xsl:for-each select="qandaentry">
291 <xsl:apply-templates select="." mode="qandatoc.mode"/>
295 <xsl:template match="qandaentry" mode="qandatoc.mode">
296 <xsl:apply-templates select="question" mode="qandatoc.mode"/>
299 <xsl:template match="question" mode="qandatoc.mode">
300 <xsl:variable name="firstch">
301 <!-- Use a titleabbrev or title if available -->
303 <xsl:when test="../blockinfo/titleabbrev">
304 <xsl:apply-templates select="../blockinfo/titleabbrev[1]/node()"/>
306 <xsl:when test="../blockinfo/title">
307 <xsl:apply-templates select="../blockinfo/title[1]/node()"/>
309 <xsl:when test="../info/titleabbrev">
310 <xsl:apply-templates select="../info/titleabbrev[1]/node()"/>
312 <xsl:when test="../titleabbrev">
313 <xsl:apply-templates select="../titleabbrev[1]/node()"/>
315 <xsl:when test="../info/title">
316 <xsl:apply-templates select="../info/title[1]/node()"/>
318 <xsl:when test="../title">
319 <xsl:apply-templates select="../title[1]/node()"/>
322 <xsl:apply-templates select="(*[local-name(.)!='label'])[1]/node()"/>
326 <xsl:variable name="deflabel">
328 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
329 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
333 <xsl:value-of select="$qanda.defaultlabel"/>
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"/>
343 <xsl:text> </xsl:text>
345 <xsl:attribute name="href">
346 <xsl:call-template name="href.target">
347 <xsl:with-param name="object" select=".."/>
350 <xsl:value-of select="$firstch"/>
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"/>
359 <xsl:template match="answer" mode="qandatoc.mode">
360 <xsl:if test="descendant::question">
362 <xsl:call-template name="process.qanda.toc"/>
367 <!-- ==================================================================== -->
369 <xsl:template name="process.qandaset">
371 <xsl:variable name="deflabel">
372 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
375 <xsl:variable name="label-width">
376 <xsl:call-template name="pi.dbhtml_label-width"/>
379 <xsl:variable name="table-summary">
380 <xsl:call-template name="pi.dbhtml_table-summary"/>
383 <xsl:variable name="cellpadding">
384 <xsl:call-template name="pi.dbhtml_cellpadding"/>
387 <xsl:variable name="cellspacing">
388 <xsl:call-template name="pi.dbhtml_cellspacing"/>
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"/>
398 <xsl:if test="$cellpadding != ''">
399 <xsl:attribute name="cellpadding">
400 <xsl:value-of select="$cellpadding"/>
404 <xsl:if test="$cellspacing != ''">
405 <xsl:attribute name="cellspacing">
406 <xsl:value-of select="$cellspacing"/>
410 <col align="{$direction.align.start}">
411 <xsl:attribute name="width">
413 <xsl:when test="$label-width != ''">
414 <xsl:value-of select="$label-width"/>
417 <xsl:text>1%</xsl:text>
424 <xsl:apply-templates select="qandaentry|qandadiv"/>
429 <!-- ==================================================================== -->
431 <xsl:template match="*" mode="no.wrapper.mode">
432 <xsl:apply-templates/>
435 <!-- ==================================================================== -->