2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
6 <!-- ********************************************************************
7 $Id: qandaset.xsl 8350 2009-03-17 07:24:29Z bobstayton $
8 ********************************************************************
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.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
18 <xsl:template match="qandaset" name="process.qandaset">
19 <xsl:variable name="id">
20 <xsl:call-template name="object.id"/>
23 <xsl:variable name="label-length">
24 <xsl:call-template name="qandaset.label.length"/>
27 <xsl:variable name="toc">
28 <xsl:call-template name="pi.dbfo_toc"/>
31 <xsl:variable name="toc.params">
32 <xsl:call-template name="find.path.params">
33 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
37 <xsl:variable name="content">
40 <xsl:when test="parent::*">
41 <xsl:if test="blockinfo/title|info/title|title">
42 <xsl:apply-templates select="(blockinfo/title|
43 info/title|title)[1]"/>
46 <!-- If it is the root element -->
48 <xsl:call-template name="qandaset.titlepage"/>
52 <xsl:if test="(contains($toc.params, 'toc') and $toc != '0')
54 <xsl:call-template name="qandaset.toc">
55 <xsl:with-param name="toc.title.p"
56 select="contains($toc.params, 'title')"/>
60 <xsl:call-template name="qandaset.toc.separator"/>
62 <xsl:apply-templates select="*[local-name(.) != 'title'
63 and local-name(.) != 'titleabbrev'
64 and local-name(.) != 'qandadiv'
65 and local-name(.) != 'qandaentry']"/>
66 <xsl:apply-templates select="qandadiv"/>
68 <xsl:if test="qandaentry">
69 <fo:list-block xsl:use-attribute-sets="list.block.spacing"
70 provisional-label-separation="0.2em">
71 <xsl:attribute name="provisional-distance-between-starts">
73 <xsl:when test="$label-length != ''">
74 <xsl:value-of select="$label-length"/>
76 <xsl:otherwise>2.5em</xsl:otherwise>
79 <xsl:apply-templates select="qandaentry"/>
86 <xsl:when test="parent::*">
87 <xsl:copy-of select="$content"/>
89 <!-- Otherwise create a page sequence -->
91 <xsl:apply-templates select="." mode="page.sequence">
92 <xsl:with-param name="content" select="$content"/>
93 <xsl:with-param name="master-reference" select="'body'"/>
94 </xsl:apply-templates>
100 <xsl:template name="qandaset.label.length">
101 <xsl:param name="deflabel">
102 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
105 <xsl:variable name="label-width">
106 <xsl:call-template name="pi.dbfo_label-width"/>
110 <xsl:when test="$label-width != ''">
111 <xsl:value-of select="$label-width"/>
113 <xsl:when test="descendant::label">
114 <xsl:call-template name="longest.term">
115 <xsl:with-param name="terms" select="descendant::label"/>
116 <xsl:with-param name="maxlength" select="20"/>
118 <xsl:text>em * 0.50</xsl:text>
120 <xsl:when test="contains($deflabel, 'qnumber') and
121 $qandadiv.autolabel != 0 and
122 $qanda.inherit.numeration != 0">
123 <xsl:text>5em</xsl:text>
125 <xsl:when test="$deflabel ='qnumber' and
126 $qandadiv.autolabel != 0 and
127 $qanda.inherit.numeration != 0">
128 <xsl:text>4em</xsl:text>
130 <xsl:when test="$deflabel = 'number'">
131 <xsl:text>3em</xsl:text>
133 <xsl:otherwise>2.5em</xsl:otherwise>
137 <xsl:template match="qandaset/blockinfo/title|qandset/info/title|qandaset/title">
138 <xsl:variable name="enclsect" select="(ancestor::section
139 | ancestor::simplesect
147 | ancestor::refsect1)[last()]"/>
148 <xsl:variable name="sectlvl">
149 <xsl:call-template name="section.level">
150 <xsl:with-param name="node" select="$enclsect"/>
154 <xsl:call-template name="qanda.heading">
155 <xsl:with-param name="level" select="$sectlvl + 1"/>
156 <xsl:with-param name="marker" select="0"/>
157 <xsl:with-param name="title">
158 <xsl:apply-templates/>
163 <xsl:template match="qandaset/blockinfo|qandaset/info">
164 <!-- what should this template really do? -->
165 <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
168 <xsl:template match="qandadiv">
169 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
172 <xsl:variable name="label-length">
173 <xsl:call-template name="qandaset.label.length"/>
176 <fo:block id="{$id}">
177 <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
178 <xsl:apply-templates select="*[local-name(.) != 'title'
179 and local-name(.) != 'titleabbrev'
180 and local-name(.) != 'qandadiv'
181 and local-name(.) != 'qandaentry']"/>
183 <xsl:apply-templates select="qandadiv"/>
185 <xsl:if test="qandaentry">
186 <fo:list-block xsl:use-attribute-sets="list.block.spacing"
187 provisional-label-separation="0.2em">
188 <xsl:attribute name="provisional-distance-between-starts">
190 <xsl:when test="$label-length != ''">
191 <xsl:value-of select="$label-length"/>
193 <xsl:otherwise>2.5em</xsl:otherwise>
196 <xsl:apply-templates select="qandaentry"/>
203 <xsl:template match="qandadiv/blockinfo/title|qandadiv/info/title|qandadiv/title">
204 <xsl:variable name="enclsect" select="(ancestor::section
205 | ancestor::simplesect
213 | ancestor::refsect1)[last()]"/>
214 <xsl:variable name="sectlvl">
215 <xsl:call-template name="section.level">
216 <xsl:with-param name="node" select="$enclsect"/>
220 <xsl:call-template name="qanda.heading">
221 <xsl:with-param name="level" select="$sectlvl + 1 + count(ancestor::qandadiv)"/>
222 <xsl:with-param name="marker" select="0"/>
223 <xsl:with-param name="title">
224 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
225 <xsl:if test="$qandadiv.autolabel != 0">
226 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
227 <xsl:text> </xsl:text>
229 <xsl:apply-templates/>
234 <xsl:template match="qandaentry">
235 <!-- Omit revhistory from fo:list-block because it is a table -->
236 <xsl:apply-templates select="question|answer"/>
239 <xsl:template match="question">
240 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
242 <xsl:variable name="entry.id">
243 <xsl:call-template name="object.id">
244 <xsl:with-param name="object" select="parent::*"/>
248 <xsl:variable name="deflabel">
249 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
253 <xsl:variable name="label.content">
254 <xsl:apply-templates select="." mode="label.markup"/>
255 <xsl:if test="contains($deflabel, 'number') and not(label)">
256 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
260 <fo:list-item id="{$entry.id}" xsl:use-attribute-sets="list.item.spacing">
261 <fo:list-item-label id="{$id}" end-indent="label-end()">
262 <xsl:if test="string-length($label.content) > 0">
263 <fo:block font-weight="bold">
264 <xsl:copy-of select="$label.content"/>
267 </fo:list-item-label>
268 <fo:list-item-body start-indent="body-start()">
270 <xsl:when test="$deflabel = 'none' and not(label)">
271 <fo:block font-weight="bold">
272 <xsl:apply-templates select="*[local-name(.)!='label']"/>
276 <xsl:apply-templates select="*[local-name(.)!='label']"/>
279 <!-- Uncomment this line to get revhistory output in the question -->
280 <!-- <xsl:apply-templates select="preceding-sibling::revhistory"/> -->
285 <xsl:template match="answer">
286 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
287 <xsl:variable name="entry.id">
288 <xsl:call-template name="object.id">
289 <xsl:with-param name="object" select="parent::*"/>
293 <xsl:variable name="deflabel">
294 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
297 <xsl:variable name="answer.label">
298 <xsl:apply-templates select="." mode="label.markup"/>
301 <fo:list-item xsl:use-attribute-sets="list.item.spacing">
302 <fo:list-item-label id="{$id}" end-indent="label-end()">
304 <xsl:when test="string-length($answer.label) > 0">
305 <fo:block font-weight="bold">
306 <xsl:copy-of select="$answer.label"/>
313 </fo:list-item-label>
314 <fo:list-item-body start-indent="body-start()">
315 <xsl:apply-templates select="*[local-name(.)!='label' and local-name(.) != 'qandaentry']"/>
316 <!-- * handle nested answer/qandaentry instances -->
317 <!-- * (bug 1509043 from Daniel Leidert) -->
318 <xsl:if test="descendant::question">
319 <xsl:call-template name="process.qandaset"/>
325 <xsl:template match="*" mode="qanda.defaultlabel">
327 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
328 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
332 <xsl:value-of select="$qanda.defaultlabel"/>
337 <xsl:template match="label">
338 <xsl:apply-templates/>
341 <xsl:template name="qanda.heading">
342 <xsl:param name="level" select="1"/>
343 <xsl:param name="marker" select="0"/>
344 <xsl:param name="title"/>
345 <xsl:param name="titleabbrev"/>
347 <fo:block xsl:use-attribute-sets="qanda.title.properties">
348 <xsl:if test="$marker != 0">
349 <fo:marker marker-class-name="section.head.marker">
351 <xsl:when test="$titleabbrev = ''">
352 <xsl:value-of select="$title"/>
355 <xsl:value-of select="$titleabbrev"/>
361 <xsl:when test="$level=1">
362 <fo:block xsl:use-attribute-sets="qanda.title.level1.properties">
363 <xsl:copy-of select="$title"/>
366 <xsl:when test="$level=2">
367 <fo:block xsl:use-attribute-sets="qanda.title.level2.properties">
368 <xsl:copy-of select="$title"/>
371 <xsl:when test="$level=3">
372 <fo:block xsl:use-attribute-sets="qanda.title.level3.properties">
373 <xsl:copy-of select="$title"/>
376 <xsl:when test="$level=4">
377 <fo:block xsl:use-attribute-sets="qanda.title.level4.properties">
378 <xsl:copy-of select="$title"/>
381 <xsl:when test="$level=5">
382 <fo:block xsl:use-attribute-sets="qanda.title.level5.properties">
383 <xsl:copy-of select="$title"/>
387 <fo:block xsl:use-attribute-sets="qanda.title.level6.properties">
388 <xsl:copy-of select="$title"/>