source: clfs-embedded/BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/qandaset.xsl@ 2bee6f1

Last change on this file since 2bee6f1 was 9882b55, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added the new lfs-xsl stylesheets.

  • Property mode set to 100644
File size: 13.9 KB
RevLine 
[9882b55]1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 version='1.0'>
5
6<!-- ********************************************************************
7 $Id$
8 ********************************************************************
9
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.
13
14 ******************************************************************** -->
15
16<!-- ==================================================================== -->
17
18<xsl:template match="qandaset" name="process.qandaset">
19 <xsl:variable name="id">
20 <xsl:call-template name="object.id"/>
21 </xsl:variable>
22
23 <xsl:variable name="label-width">
24 <xsl:call-template name="pi.dbfo_label-width"/>
25 </xsl:variable>
26
27 <xsl:variable name="label-length">
28 <xsl:choose>
29 <xsl:when test="$label-width != ''">
30 <xsl:value-of select="$label-width"/>
31 </xsl:when>
32 <xsl:when test="descendant::label">
33 <xsl:call-template name="longest.term">
34 <xsl:with-param name="terms" select="descendant::label"/>
35 <xsl:with-param name="maxlength" select="20"/>
36 </xsl:call-template>
37 <xsl:text>em * 0.50</xsl:text>
38 </xsl:when>
39 <xsl:otherwise>2.5em</xsl:otherwise>
40 </xsl:choose>
41 </xsl:variable>
42
43 <xsl:variable name="toc">
44 <xsl:call-template name="pi.dbfo_toc"/>
45 </xsl:variable>
46
47 <xsl:variable name="toc.params">
48 <xsl:call-template name="find.path.params">
49 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
50 </xsl:call-template>
51 </xsl:variable>
52
53 <xsl:variable name="content">
54 <fo:block id="{$id}">
55 <xsl:choose>
56 <xsl:when test="parent::*">
57 <xsl:if test="blockinfo/title|info/title|title">
58 <xsl:apply-templates select="(blockinfo/title|
59 info/title|title)[1]"/>
60 </xsl:if>
61 </xsl:when>
62 <!-- If it is the root element -->
63 <xsl:otherwise>
64 <xsl:call-template name="qandaset.titlepage"/>
65 </xsl:otherwise>
66 </xsl:choose>
67
68 <xsl:if test="(contains($toc.params, 'toc') and $toc != '0')
69 or $toc = '1'">
70 <xsl:call-template name="qandaset.toc">
71 <xsl:with-param name="toc.title.p"
72 select="contains($toc.params, 'title')"/>
73 </xsl:call-template>
74 </xsl:if>
75
76 <xsl:call-template name="qandaset.toc.separator"/>
77
78 <xsl:apply-templates select="*[local-name(.) != 'title'
79 and local-name(.) != 'titleabbrev'
80 and local-name(.) != 'qandadiv'
81 and local-name(.) != 'qandaentry']"/>
82 <xsl:apply-templates select="qandadiv"/>
83
84 <xsl:if test="qandaentry">
85 <fo:list-block xsl:use-attribute-sets="list.block.spacing"
86 provisional-label-separation="0.2em">
87 <xsl:attribute name="provisional-distance-between-starts">
88 <xsl:choose>
89 <xsl:when test="$label-length != ''">
90 <xsl:value-of select="$label-length"/>
91 </xsl:when>
92 <xsl:otherwise>2.5em</xsl:otherwise>
93 </xsl:choose>
94 </xsl:attribute>
95 <xsl:apply-templates select="qandaentry"/>
96 </fo:list-block>
97 </xsl:if>
98 </fo:block>
99 </xsl:variable>
100
101 <xsl:choose>
102 <xsl:when test="parent::*">
103 <xsl:copy-of select="$content"/>
104 </xsl:when>
105 <!-- Otherwise create a page sequence -->
106 <xsl:otherwise>
107 <xsl:apply-templates select="." mode="page.sequence">
108 <xsl:with-param name="content" select="$content"/>
109 <xsl:with-param name="master-reference" select="'body'"/>
110 </xsl:apply-templates>
111 </xsl:otherwise>
112 </xsl:choose>
113
114</xsl:template>
115
116<xsl:template match="qandaset/blockinfo/title|qandset/info/title|qandaset/title">
117 <xsl:variable name="enclsect" select="(ancestor::section
118 | ancestor::simplesect
119 | ancestor::sect5
120 | ancestor::sect4
121 | ancestor::sect3
122 | ancestor::sect2
123 | ancestor::sect1
124 | ancestor::refsect3
125 | ancestor::refsect2
126 | ancestor::refsect1)[last()]"/>
127 <xsl:variable name="sectlvl">
128 <xsl:call-template name="section.level">
129 <xsl:with-param name="node" select="$enclsect"/>
130 </xsl:call-template>
131 </xsl:variable>
132
133 <xsl:call-template name="qanda.heading">
134 <xsl:with-param name="level" select="$sectlvl + 1"/>
135 <xsl:with-param name="marker" select="0"/>
136 <xsl:with-param name="title">
137 <xsl:apply-templates/>
138 </xsl:with-param>
139 </xsl:call-template>
140</xsl:template>
141
142<xsl:template match="qandaset/blockinfo|qandaset/info">
143 <!-- what should this template really do? -->
144 <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
145</xsl:template>
146
147<xsl:template match="qandadiv">
148 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
149
150 <xsl:variable name="label-width">
151 <xsl:call-template name="pi.dbfo_label-width"/>
152 </xsl:variable>
153
154 <xsl:variable name="label-length">
155 <xsl:choose>
156 <xsl:when test="$label-width != ''">
157 <xsl:value-of select="$label-width"/>
158 </xsl:when>
159 <xsl:when test="descendant::label">
160 <xsl:call-template name="longest.term">
161 <xsl:with-param name="terms" select="descendant::label"/>
162 <xsl:with-param name="maxlength" select="20"/>
163 </xsl:call-template>
164 <xsl:text>*0.6em</xsl:text>
165 </xsl:when>
166 <xsl:otherwise>2.5em</xsl:otherwise>
167 </xsl:choose>
168 </xsl:variable>
169
170 <fo:block id="{$id}">
171 <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
172 <xsl:apply-templates select="*[local-name(.) != 'title'
173 and local-name(.) != 'titleabbrev'
174 and local-name(.) != 'qandadiv'
175 and local-name(.) != 'qandaentry']"/>
176 <fo:block>
177 <xsl:apply-templates select="qandadiv"/>
178
179 <xsl:if test="qandaentry">
180 <fo:list-block xsl:use-attribute-sets="list.block.spacing"
181 provisional-label-separation="0.2em">
182 <xsl:attribute name="provisional-distance-between-starts">
183 <xsl:choose>
184 <xsl:when test="$label-length != ''">
185 <xsl:value-of select="$label-length"/>
186 </xsl:when>
187 <xsl:otherwise>2.5em</xsl:otherwise>
188 </xsl:choose>
189 </xsl:attribute>
190 <xsl:apply-templates select="qandaentry"/>
191 </fo:list-block>
192 </xsl:if>
193 </fo:block>
194 </fo:block>
195</xsl:template>
196
197<xsl:template match="qandadiv/blockinfo/title|qandadiv/info/title|qandadiv/title">
198 <xsl:variable name="enclsect" select="(ancestor::section
199 | ancestor::simplesect
200 | ancestor::sect5
201 | ancestor::sect4
202 | ancestor::sect3
203 | ancestor::sect2
204 | ancestor::sect1
205 | ancestor::refsect3
206 | ancestor::refsect2
207 | ancestor::refsect1)[last()]"/>
208 <xsl:variable name="sectlvl">
209 <xsl:call-template name="section.level">
210 <xsl:with-param name="node" select="$enclsect"/>
211 </xsl:call-template>
212 </xsl:variable>
213
214 <xsl:call-template name="qanda.heading">
215 <xsl:with-param name="level" select="$sectlvl + 1 + count(ancestor::qandadiv)"/>
216 <xsl:with-param name="marker" select="0"/>
217 <xsl:with-param name="title">
218 <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
219 <xsl:if test="$qandadiv.autolabel != 0">
220 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
221 <xsl:text> </xsl:text>
222 </xsl:if>
223 <xsl:apply-templates/>
224 </xsl:with-param>
225 </xsl:call-template>
226</xsl:template>
227
228<xsl:template match="qandaentry">
229 <!-- Omit revhistory from fo:list-block because it is a table -->
230 <xsl:apply-templates select="question|answer"/>
231</xsl:template>
232
233<xsl:template match="question">
234 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
235
236 <xsl:variable name="entry.id">
237 <xsl:call-template name="object.id">
238 <xsl:with-param name="object" select="parent::*"/>
239 </xsl:call-template>
240 </xsl:variable>
241
242 <xsl:variable name="deflabel">
243 <xsl:choose>
244 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
245 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
246 /@defaultlabel"/>
247 </xsl:when>
248 <xsl:otherwise>
249 <xsl:value-of select="$qanda.defaultlabel"/>
250 </xsl:otherwise>
251 </xsl:choose>
252 </xsl:variable>
253
254
255 <xsl:variable name="label.content">
256 <xsl:apply-templates select="." mode="label.markup"/>
257 <xsl:if test="$deflabel = 'number' and not(label)">
258 <xsl:apply-templates select="." mode="intralabel.punctuation"/>
259 </xsl:if>
260 </xsl:variable>
261
262 <fo:list-item id="{$entry.id}" xsl:use-attribute-sets="list.item.spacing">
263 <fo:list-item-label id="{$id}" end-indent="label-end()">
264 <xsl:if test="string-length($label.content) &gt; 0">
265 <fo:block font-weight="bold">
266 <xsl:copy-of select="$label.content"/>
267 </fo:block>
268 </xsl:if>
269 </fo:list-item-label>
270 <fo:list-item-body start-indent="body-start()">
271 <xsl:choose>
272 <xsl:when test="$deflabel = 'none' and not(label)">
273 <fo:block font-weight="bold">
274 <xsl:apply-templates select="*[local-name(.)!='label']"/>
275 </fo:block>
276 </xsl:when>
277 <xsl:otherwise>
278 <xsl:apply-templates select="*[local-name(.)!='label']"/>
279 </xsl:otherwise>
280 </xsl:choose>
281 <!-- Uncomment this line to get revhistory output in the question -->
282 <!-- <xsl:apply-templates select="preceding-sibling::revhistory"/> -->
283 </fo:list-item-body>
284 </fo:list-item>
285</xsl:template>
286
287<xsl:template match="answer">
288 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
289 <xsl:variable name="entry.id">
290 <xsl:call-template name="object.id">
291 <xsl:with-param name="object" select="parent::*"/>
292 </xsl:call-template>
293 </xsl:variable>
294
295 <xsl:variable name="deflabel">
296 <xsl:choose>
297 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
298 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
299 /@defaultlabel"/>
300 </xsl:when>
301 <xsl:otherwise>
302 <xsl:value-of select="$qanda.defaultlabel"/>
303 </xsl:otherwise>
304 </xsl:choose>
305 </xsl:variable>
306
307 <xsl:variable name="answer.label">
308 <xsl:apply-templates select="." mode="label.markup"/>
309 </xsl:variable>
310
311 <fo:list-item xsl:use-attribute-sets="list.item.spacing">
312 <fo:list-item-label id="{$id}" end-indent="label-end()">
313 <xsl:choose>
314 <xsl:when test="string-length($answer.label) &gt; 0">
315 <fo:block font-weight="bold">
316 <xsl:copy-of select="$answer.label"/>
317 </fo:block>
318 </xsl:when>
319 <xsl:otherwise>
320 <fo:block/>
321 </xsl:otherwise>
322 </xsl:choose>
323 </fo:list-item-label>
324 <fo:list-item-body start-indent="body-start()">
325 <xsl:apply-templates select="*[local-name(.)!='label' and local-name(.) != 'qandaentry']"/>
326 <!-- * handle nested answer/qandaentry instances -->
327 <!-- * (bug 1509043 from Daniel Leidert) -->
328 <xsl:if test="descendant::question">
329 <xsl:call-template name="process.qandaset"/>
330 </xsl:if>
331 </fo:list-item-body>
332 </fo:list-item>
333</xsl:template>
334
335<xsl:template match="label">
336 <xsl:apply-templates/>
337</xsl:template>
338
339<xsl:template name="qanda.heading">
340 <xsl:param name="level" select="1"/>
341 <xsl:param name="marker" select="0"/>
342 <xsl:param name="title"/>
343 <xsl:param name="titleabbrev"/>
344
345 <fo:block xsl:use-attribute-sets="qanda.title.properties">
346 <xsl:if test="$marker != 0">
347 <fo:marker marker-class-name="section.head.marker">
348 <xsl:choose>
349 <xsl:when test="$titleabbrev = ''">
350 <xsl:value-of select="$title"/>
351 </xsl:when>
352 <xsl:otherwise>
353 <xsl:value-of select="$titleabbrev"/>
354 </xsl:otherwise>
355 </xsl:choose>
356 </fo:marker>
357 </xsl:if>
358 <xsl:choose>
359 <xsl:when test="$level=1">
360 <fo:block xsl:use-attribute-sets="qanda.title.level1.properties">
361 <xsl:copy-of select="$title"/>
362 </fo:block>
363 </xsl:when>
364 <xsl:when test="$level=2">
365 <fo:block xsl:use-attribute-sets="qanda.title.level2.properties">
366 <xsl:copy-of select="$title"/>
367 </fo:block>
368 </xsl:when>
369 <xsl:when test="$level=3">
370 <fo:block xsl:use-attribute-sets="qanda.title.level3.properties">
371 <xsl:copy-of select="$title"/>
372 </fo:block>
373 </xsl:when>
374 <xsl:when test="$level=4">
375 <fo:block xsl:use-attribute-sets="qanda.title.level4.properties">
376 <xsl:copy-of select="$title"/>
377 </fo:block>
378 </xsl:when>
379 <xsl:when test="$level=5">
380 <fo:block xsl:use-attribute-sets="qanda.title.level5.properties">
381 <xsl:copy-of select="$title"/>
382 </fo:block>
383 </xsl:when>
384 <xsl:otherwise>
385 <fo:block xsl:use-attribute-sets="qanda.title.level6.properties">
386 <xsl:copy-of select="$title"/>
387 </fo:block>
388 </xsl:otherwise>
389 </xsl:choose>
390 </fo:block>
391</xsl:template>
392
393</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.