source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/index.xsl@ 5ac1c94

clfs-3.0.0-systemd systemd
Last change on this file since 5ac1c94 was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 17.1 KB
RevLine 
[f8c4e94]1<?xml version='1.0'?>
2<!DOCTYPE xsl:stylesheet [
3<!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
4<!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas)]))'>
5<!ENTITY tertiary 'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas)]))'>
6]>
7<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 xmlns:fo="http://www.w3.org/1999/XSL/Format"
9 xmlns:rx="http://www.renderx.com/XSL/Extensions"
10 version='1.0'>
11
12<!-- ********************************************************************
13 $Id$
14 ********************************************************************
15
16 This file is part of the XSL DocBook Stylesheet distribution.
17 See ../README or http://docbook.sf.net/release/xsl/current/ for
18 copyright and other information.
19
20 ******************************************************************** -->
21
22<!-- ==================================================================== -->
23
24<xsl:template match="index">
25 <xsl:variable name="id">
26 <xsl:call-template name="object.id"/>
27 </xsl:variable>
28
29 <xsl:if test="$generate.index != 0">
30 <xsl:choose>
31 <xsl:when test="$make.index.markup != 0">
32 <fo:block>
33 <xsl:call-template name="generate-index-markup">
34 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
35 </xsl:call-template>
36 </fo:block>
37 </xsl:when>
38 <xsl:otherwise>
39 <fo:block id="{$id}">
40 <xsl:call-template name="index.titlepage"/>
41 </fo:block>
42 <xsl:apply-templates/>
43 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
44 <xsl:call-template name="generate-index">
45 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
46 </xsl:call-template>
47 </xsl:if>
48 </xsl:otherwise>
49 </xsl:choose>
50 </xsl:if>
51</xsl:template>
52
53<xsl:template match="book/index|part/index">
54 <xsl:variable name="id">
55 <xsl:call-template name="object.id"/>
56 </xsl:variable>
57
58 <xsl:if test="$generate.index != 0">
59 <xsl:variable name="master-reference">
60 <xsl:call-template name="select.pagemaster">
61 <xsl:with-param name="pageclass">
62 <xsl:if test="$make.index.markup != 0">body</xsl:if>
63 </xsl:with-param>
64 </xsl:call-template>
65 </xsl:variable>
66
67 <fo:page-sequence hyphenate="{$hyphenate}"
68 master-reference="{$master-reference}">
69 <xsl:attribute name="language">
70 <xsl:call-template name="l10n.language"/>
71 </xsl:attribute>
72 <xsl:attribute name="format">
73 <xsl:call-template name="page.number.format">
74 <xsl:with-param name="master-reference" select="$master-reference"/>
75 </xsl:call-template>
76 </xsl:attribute>
77
78 <xsl:attribute name="initial-page-number">
79 <xsl:call-template name="initial.page.number">
80 <xsl:with-param name="master-reference" select="$master-reference"/>
81 </xsl:call-template>
82 </xsl:attribute>
83
84 <xsl:attribute name="force-page-count">
85 <xsl:call-template name="force.page.count">
86 <xsl:with-param name="master-reference" select="$master-reference"/>
87 </xsl:call-template>
88 </xsl:attribute>
89
90 <xsl:attribute name="hyphenation-character">
91 <xsl:call-template name="gentext">
92 <xsl:with-param name="key" select="'hyphenation-character'"/>
93 </xsl:call-template>
94 </xsl:attribute>
95 <xsl:attribute name="hyphenation-push-character-count">
96 <xsl:call-template name="gentext">
97 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
98 </xsl:call-template>
99 </xsl:attribute>
100 <xsl:attribute name="hyphenation-remain-character-count">
101 <xsl:call-template name="gentext">
102 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
103 </xsl:call-template>
104 </xsl:attribute>
105
106 <xsl:apply-templates select="." mode="running.head.mode">
107 <xsl:with-param name="master-reference" select="$master-reference"/>
108 </xsl:apply-templates>
109 <xsl:apply-templates select="." mode="running.foot.mode">
110 <xsl:with-param name="master-reference" select="$master-reference"/>
111 </xsl:apply-templates>
112
113 <fo:flow flow-name="xsl-region-body">
114 <xsl:call-template name="set.flow.properties">
115 <xsl:with-param name="element" select="local-name(.)"/>
116 <xsl:with-param name="master-reference" select="$master-reference"/>
117 </xsl:call-template>
118
119 <fo:block id="{$id}">
120 <xsl:call-template name="index.titlepage"/>
121 </fo:block>
122 <xsl:apply-templates/>
123 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
124
125 <xsl:choose>
126 <xsl:when test="$make.index.markup != 0">
127 <fo:block wrap-option='no-wrap'
128 white-space-collapse='false'
129 xsl:use-attribute-sets="monospace.verbatim.properties"
130 linefeed-treatment="preserve">
131 <xsl:call-template name="generate-index-markup">
132 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
133 </xsl:call-template>
134 </fo:block>
135 </xsl:when>
136 <xsl:when test="indexentry|indexdiv/indexentry">
137 <xsl:apply-templates/>
138 </xsl:when>
139 <xsl:otherwise>
140 <xsl:call-template name="generate-index">
141 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
142 </xsl:call-template>
143 </xsl:otherwise>
144 </xsl:choose>
145 </xsl:if>
146 </fo:flow>
147 </fo:page-sequence>
148 </xsl:if>
149</xsl:template>
150
151<xsl:template match="setindex">
152 <xsl:variable name="id">
153 <xsl:call-template name="object.id"/>
154 </xsl:variable>
155
156 <xsl:if test="$generate.index != 0">
157 <xsl:variable name="master-reference">
158 <xsl:call-template name="select.pagemaster">
159 <xsl:with-param name="pageclass">
160 <xsl:choose>
161 <xsl:when test="$make.index.markup != 0">body</xsl:when>
162 <xsl:otherwise>index</xsl:otherwise>
163 </xsl:choose>
164 </xsl:with-param>
165 </xsl:call-template>
166 </xsl:variable>
167
168 <fo:page-sequence hyphenate="{$hyphenate}"
169 master-reference="{$master-reference}">
170 <xsl:attribute name="language">
171 <xsl:call-template name="l10n.language"/>
172 </xsl:attribute>
173 <xsl:attribute name="format">
174 <xsl:call-template name="page.number.format">
175 <xsl:with-param name="master-reference" select="$master-reference"/>
176 </xsl:call-template>
177 </xsl:attribute>
178
179 <xsl:attribute name="initial-page-number">
180 <xsl:call-template name="initial.page.number">
181 <xsl:with-param name="master-reference" select="$master-reference"/>
182 </xsl:call-template>
183 </xsl:attribute>
184
185 <xsl:attribute name="force-page-count">
186 <xsl:call-template name="force.page.count">
187 <xsl:with-param name="master-reference" select="$master-reference"/>
188 </xsl:call-template>
189 </xsl:attribute>
190
191 <xsl:attribute name="hyphenation-character">
192 <xsl:call-template name="gentext">
193 <xsl:with-param name="key" select="'hyphenation-character'"/>
194 </xsl:call-template>
195 </xsl:attribute>
196 <xsl:attribute name="hyphenation-push-character-count">
197 <xsl:call-template name="gentext">
198 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
199 </xsl:call-template>
200 </xsl:attribute>
201 <xsl:attribute name="hyphenation-remain-character-count">
202 <xsl:call-template name="gentext">
203 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
204 </xsl:call-template>
205 </xsl:attribute>
206
207 <xsl:apply-templates select="." mode="running.head.mode">
208 <xsl:with-param name="master-reference" select="$master-reference"/>
209 </xsl:apply-templates>
210 <xsl:apply-templates select="." mode="running.foot.mode">
211 <xsl:with-param name="master-reference" select="$master-reference"/>
212 </xsl:apply-templates>
213
214 <fo:flow flow-name="xsl-region-body">
215 <xsl:call-template name="set.flow.properties">
216 <xsl:with-param name="element" select="local-name(.)"/>
217 <xsl:with-param name="master-reference" select="$master-reference"/>
218 </xsl:call-template>
219
220 <fo:block id="{$id}">
221 <xsl:call-template name="setindex.titlepage"/>
222 </fo:block>
223 <xsl:apply-templates/>
224 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
225
226 <xsl:choose>
227 <xsl:when test="$make.index.markup != 0">
228 <fo:block wrap-option='no-wrap'
229 white-space-collapse='false'
230 xsl:use-attribute-sets="monospace.verbatim.properties"
231 linefeed-treatment="preserve">
232 <xsl:call-template name="generate-index-markup">
233 <xsl:with-param name="scope" select="/"/>
234 </xsl:call-template>
235 </fo:block>
236 </xsl:when>
237 <xsl:when test="indexentry|indexdiv/indexentry">
238 <xsl:apply-templates/>
239 </xsl:when>
240 <xsl:otherwise>
241 <xsl:call-template name="generate-index">
242 <xsl:with-param name="scope" select="/"/>
243 </xsl:call-template>
244 </xsl:otherwise>
245 </xsl:choose>
246 </xsl:if>
247 </fo:flow>
248 </fo:page-sequence>
249 </xsl:if>
250</xsl:template>
251
252<xsl:template match="index/indexinfo"></xsl:template>
253<xsl:template match="index/info"></xsl:template>
254<xsl:template match="index/title"></xsl:template>
255<xsl:template match="index/subtitle"></xsl:template>
256<xsl:template match="index/titleabbrev"></xsl:template>
257
258<!-- ==================================================================== -->
259
260<xsl:template name="indexdiv.title">
261 <xsl:param name="title"/>
262 <xsl:param name="titlecontent"/>
263
264 <fo:block xsl:use-attribute-sets="index.div.title.properties">
265 <xsl:choose>
266 <xsl:when test="$title">
267 <xsl:apply-templates select="." mode="object.title.markup">
268 <xsl:with-param name="allow-anchors" select="1"/>
269 </xsl:apply-templates>
270 </xsl:when>
271 <xsl:otherwise>
272 <xsl:copy-of select="$titlecontent"/>
273 </xsl:otherwise>
274 </xsl:choose>
275 </fo:block>
276</xsl:template>
277
278<xsl:template match="indexdiv">
279 <fo:block>
280 <xsl:call-template name="indexdiv.titlepage"/>
281 <xsl:apply-templates/>
282 </fo:block>
283</xsl:template>
284
285<xsl:template match="indexdiv/title"/>
286<xsl:template match="indexdiv/subtitle"/>
287<xsl:template match="indexdiv/titleabbrev"/>
288
289<!-- ==================================================================== -->
290
291<!-- Text used for distiguishing between normal and significant entries -->
292<xsl:variable name="significant.flag">.tnacifingis</xsl:variable>
293
294<xsl:template match="indexterm" name="indexterm">
295 <!-- Temporal workaround for bug in AXF -->
296 <xsl:variable name="wrapper.name">
297 <xsl:choose>
298 <xsl:when test="$axf.extensions != 0">
299 <xsl:call-template name="inline.or.block"/>
300 </xsl:when>
301 <xsl:otherwise>fo:wrapper</xsl:otherwise>
302 </xsl:choose>
303 </xsl:variable>
304
305 <xsl:element name="{$wrapper.name}">
306 <xsl:attribute name="id">
307 <xsl:call-template name="object.id"/>
308 </xsl:attribute>
309 <xsl:choose>
310 <xsl:when test="$xep.extensions != 0">
311 <xsl:attribute name="rx:key">
312 <xsl:value-of select="&primary;"/>
313 <xsl:if test="@significance='preferred'"><xsl:value-of select="$significant.flag"/></xsl:if>
314 <xsl:if test="secondary">
315 <xsl:text>, </xsl:text>
316 <xsl:value-of select="&secondary;"/>
317 </xsl:if>
318 <xsl:if test="tertiary">
319 <xsl:text>, </xsl:text>
320 <xsl:value-of select="&tertiary;"/>
321 </xsl:if>
322 </xsl:attribute>
323 </xsl:when>
324 <xsl:otherwise>
325 <xsl:comment>
326 <xsl:call-template name="comment-escape-string">
327 <xsl:with-param name="string">
328 <xsl:value-of select="primary"/>
329 <xsl:if test="secondary">
330 <xsl:text>, </xsl:text>
331 <xsl:value-of select="secondary"/>
332 </xsl:if>
333 <xsl:if test="tertiary">
334 <xsl:text>, </xsl:text>
335 <xsl:value-of select="tertiary"/>
336 </xsl:if>
337 </xsl:with-param>
338 </xsl:call-template>
339 </xsl:comment>
340 </xsl:otherwise>
341 </xsl:choose>
342 </xsl:element>
343</xsl:template>
344
345<xsl:template match="indexterm[@class='startofrange']">
346 <xsl:choose>
347 <xsl:when test="$xep.extensions != 0">
348 <rx:begin-index-range>
349 <xsl:call-template name="anchor"/>
350 <xsl:attribute name="rx:key">
351 <xsl:value-of select="&primary;"/>
352 <xsl:if test="@significance='preferred'"><xsl:value-of select="$significant.flag"/></xsl:if>
353 <xsl:if test="secondary">
354 <xsl:text>, </xsl:text>
355 <xsl:value-of select="&secondary;"/>
356 </xsl:if>
357 <xsl:if test="tertiary">
358 <xsl:text>, </xsl:text>
359 <xsl:value-of select="&tertiary;"/>
360 </xsl:if>
361 </xsl:attribute>
362 </rx:begin-index-range>
363 </xsl:when>
364 <xsl:otherwise>
365 <xsl:call-template name="indexterm"/>
366 </xsl:otherwise>
367 </xsl:choose>
368</xsl:template>
369
370<xsl:template match="indexterm[@class='endofrange']">
371 <xsl:choose>
372 <xsl:when test="$xep.extensions != 0">
373 <rx:end-index-range>
374 <xsl:attribute name="ref-id">
375 <xsl:value-of select="@startref"/>
376 </xsl:attribute>
377 </rx:end-index-range>
378 </xsl:when>
379 <xsl:otherwise>
380 <xsl:call-template name="indexterm"/>
381 </xsl:otherwise>
382 </xsl:choose>
383</xsl:template>
384
385<!-- ==================================================================== -->
386
387<xsl:template match="indexentry">
388 <fo:block>
389 <!-- don't process 'seeie's from here -->
390 <xsl:apply-templates select="primaryie|secondaryie|tertiaryie|seealsoie"/>
391 </fo:block>
392</xsl:template>
393
394<xsl:template match="primaryie">
395 <fo:block>
396 <xsl:apply-templates/>
397 <xsl:if test="following-sibling::seeie">
398 <xsl:text> (</xsl:text>
399 <xsl:call-template name="gentext">
400 <xsl:with-param name="key" select="'see'"/>
401 </xsl:call-template>
402 <xsl:text> </xsl:text>
403 <xsl:apply-templates select="following-sibling::seeie"/>
404 <xsl:text>)</xsl:text>
405 </xsl:if>
406 </fo:block>
407</xsl:template>
408
409<xsl:template match="secondaryie">
410 <fo:block start-indent="1pc">
411 <xsl:apply-templates/>
412 <xsl:if test="following-sibling::seeie">
413 <xsl:text> (</xsl:text>
414 <xsl:call-template name="gentext">
415 <xsl:with-param name="key" select="'see'"/>
416 </xsl:call-template>
417 <xsl:text> </xsl:text>
418 <xsl:apply-templates select="following-sibling::seeie"/>
419 <xsl:text>)</xsl:text>
420 </xsl:if>
421 </fo:block>
422</xsl:template>
423
424<xsl:template match="tertiaryie">
425 <fo:block start-indent="2pc">
426 <xsl:apply-templates/>
427 <xsl:if test="following-sibling::seeie">
428 <xsl:text> (</xsl:text>
429 <xsl:call-template name="gentext">
430 <xsl:with-param name="key" select="'see'"/>
431 </xsl:call-template>
432 <xsl:text> </xsl:text>
433 <xsl:apply-templates select="following-sibling::seeie"/>
434 <xsl:text>)</xsl:text>
435 </xsl:if>
436 </fo:block>
437</xsl:template>
438
439<xsl:template match="seeie">
440 <fo:inline>
441 <xsl:apply-templates/>
442 </fo:inline>
443</xsl:template>
444
445<xsl:template match="seealsoie">
446 <fo:block>
447 <xsl:attribute name="start-indent">
448 <xsl:choose>
449 <xsl:when test="preceding-sibling::tertiaryie">3pc</xsl:when>
450 <xsl:when test="preceding-sibling::secondaryie">2pc</xsl:when>
451 <xsl:otherwise>1pc</xsl:otherwise>
452 </xsl:choose>
453 </xsl:attribute>
454 <xsl:text>(</xsl:text>
455 <xsl:call-template name="gentext">
456 <xsl:with-param name="key" select="'seealso'"/>
457 </xsl:call-template>
458 <xsl:text> </xsl:text>
459 <xsl:apply-templates/>
460 <xsl:text>)</xsl:text>
461 </fo:block>
462</xsl:template>
463
464<!-- Determines if an object should be inserted as an fo:inline
465 or an fo:block. Used for indexterms -->
466<xsl:template name="inline.or.block">
467 <xsl:param name="parentnode" select=".."/>
468
469 <xsl:variable name="parent" select="local-name($parentnode)"/>
470
471 <xsl:variable name="block.parents" select="'|answer|appendix|appendixinfo|article|articleinfo|bibliodiv|bibliography|bibliographyinfo|blockinfo|blockquote|bookinfo|callout|caution|chapter|chapterinfo|dedication|example|figure|formalpara|funcsynopsisinfo|glossary|glossaryinfo|glossdef|glossdiv|glossentry|highlights|important|index|indexinfo|info|informalexample|informalfigure|informaltable|itemizedlist|legalnotice|listitem|msgexplan|msgtext|note|objectinfo|orderedlist|partinfo|partintro|preface|prefaceinfo|procedure|qandadiv|qandaset|question|refentry|refentryinfo|referenceinfo|refmeta|refmiscinfo|refsect1|refsect1info|refsect2|refsect2info|refsect3|refsect3info|refsection|refsectioninfo|refsynopsisdiv|refsynopsisdivinfo|revdescription|screeninfo|sect1|sect1info|sect2|sect2info|sect3|sect3info|sect4|sect4info|sect5|sect5info|section|sectioninfo|setindex|setindexinfo|setinfo|sidebar|sidebarinfo|simplesect|step|table|task|taskprerequisites|taskrelated|tasksummary|tip|variablelist|warning|'"/>
472
473 <xsl:choose>
474 <xsl:when test="contains($parent, $block.parents)">fo:block</xsl:when>
475 <xsl:otherwise>fo:inline</xsl:otherwise>
476 </xsl:choose>
477</xsl:template>
478
479</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.