2 <xsl:stylesheet exclude-result-prefixes="d"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:d="http://docbook.org/ns/docbook"
5 xmlns:fo="http://www.w3.org/1999/XSL/Format"
8 <!-- ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://cdn.docbook.org/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
18 <xsl:template match="d: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="d:blockinfo/d:title|d:info/d:title|d:title">
42 <xsl:apply-templates select="(d:blockinfo/d:title|
43 d:info/d:title|d: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="d:qandadiv"/>
68 <xsl:if test="d: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="d: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::d:label">
114 <xsl:call-template name="longest.term">
115 <xsl:with-param name="terms" select="descendant::d: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="d:qandaset/d:blockinfo/d:title|d:qandset/d:info/d:title|d:qandaset/d:title">
138 <xsl:variable name="enclsect" select="(ancestor::d:section
139 | ancestor::d:simplesect
145 | ancestor::d:refsect3
146 | ancestor::d:refsect2
147 | ancestor::d: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="d:qandaset/d:blockinfo|d:qandaset/d:info">
164 <!-- what should this template really do? -->
165 <xsl:apply-templates select="d:legalnotice" mode="titlepage.mode"/>
168 <xsl:template match="d: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="(d:blockinfo/d:title|d:info/d:title|d: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="d:qandadiv"/>
185 <xsl:if test="d: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="d:qandaentry"/>
203 <xsl:template match="d:qandadiv/d:blockinfo/d:title|d:qandadiv/d:info/d:title|d:qandadiv/d:title">
204 <xsl:variable name="enclsect" select="(ancestor::d:section
205 | ancestor::d:simplesect
211 | ancestor::d:refsect3
212 | ancestor::d:refsect2
213 | ancestor::d: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::d:qandadiv)"/>
222 <xsl:with-param name="marker" select="0"/>
223 <xsl:with-param name="title">
224 <xsl:apply-templates select="parent::d: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="d:qandaentry">
235 <!-- Omit revhistory from fo:list-block because it is a table -->
236 <xsl:apply-templates select="d:question|d:answer"/>
239 <xsl:template match="d: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(d: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()">
263 <xsl:when test="string-length($label.content) > 0">
264 <fo:block font-weight="bold">
265 <xsl:copy-of select="$label.content"/>
272 </fo:list-item-label>
273 <fo:list-item-body start-indent="body-start()">
275 <xsl:when test="$deflabel = 'none' and not(d:label)">
276 <fo:block font-weight="bold">
277 <xsl:apply-templates select="*[local-name(.)!='label']"/>
281 <xsl:apply-templates select="*[local-name(.)!='label']"/>
284 <!-- Uncomment this line to get revhistory output in the question -->
285 <!-- <xsl:apply-templates select="preceding-sibling::d:revhistory"/> -->
290 <xsl:template match="d:answer">
291 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
292 <xsl:variable name="entry.id">
293 <xsl:call-template name="object.id">
294 <xsl:with-param name="object" select="parent::*"/>
298 <xsl:variable name="deflabel">
299 <xsl:apply-templates select="." mode="qanda.defaultlabel"/>
302 <xsl:variable name="answer.label">
303 <xsl:apply-templates select="." mode="label.markup"/>
306 <fo:list-item xsl:use-attribute-sets="list.item.spacing">
307 <fo:list-item-label id="{$id}" end-indent="label-end()">
309 <xsl:when test="string-length($answer.label) > 0">
310 <fo:block font-weight="bold">
311 <xsl:copy-of select="$answer.label"/>
318 </fo:list-item-label>
319 <fo:list-item-body start-indent="body-start()">
320 <xsl:apply-templates select="*[local-name(.)!='label' and local-name(.) != 'qandaentry']"/>
321 <!-- * handle nested answer/qandaentry instances -->
322 <!-- * (bug 1509043 from Daniel Leidert) -->
323 <xsl:if test="descendant::d:question">
324 <xsl:call-template name="process.qandaset"/>
330 <xsl:template match="*" mode="qanda.defaultlabel">
332 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
333 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
337 <xsl:value-of select="$qanda.defaultlabel"/>
342 <xsl:template match="d:label">
343 <xsl:apply-templates/>
346 <xsl:template name="qanda.heading">
347 <xsl:param name="level" select="1"/>
348 <xsl:param name="marker" select="0"/>
349 <xsl:param name="title"/>
350 <xsl:param name="titleabbrev"/>
352 <fo:block xsl:use-attribute-sets="qanda.title.properties">
353 <xsl:if test="$marker != 0">
354 <fo:marker marker-class-name="section.head.marker">
356 <xsl:when test="$titleabbrev = ''">
357 <xsl:value-of select="$title"/>
360 <xsl:value-of select="$titleabbrev"/>
366 <xsl:when test="$level=1">
367 <fo:block xsl:use-attribute-sets="qanda.title.level1.properties">
368 <xsl:copy-of select="$title"/>
371 <xsl:when test="$level=2">
372 <fo:block xsl:use-attribute-sets="qanda.title.level2.properties">
373 <xsl:copy-of select="$title"/>
376 <xsl:when test="$level=3">
377 <fo:block xsl:use-attribute-sets="qanda.title.level3.properties">
378 <xsl:copy-of select="$title"/>
381 <xsl:when test="$level=4">
382 <fo:block xsl:use-attribute-sets="qanda.title.level4.properties">
383 <xsl:copy-of select="$title"/>
386 <xsl:when test="$level=5">
387 <fo:block xsl:use-attribute-sets="qanda.title.level5.properties">
388 <xsl:copy-of select="$title"/>
392 <fo:block xsl:use-attribute-sets="qanda.title.level6.properties">
393 <xsl:copy-of select="$title"/>