]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/fo/index.xsl
Add stylesheets for our evergreen docbook site.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / fo / index.xsl
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: index.xsl 8317 2009-03-12 06:14:02Z bobstayton $
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:use-attribute-sets="component.titlepage.properties">
121         <xsl:call-template name="index.titlepage"/>
122       </fo:block>
123       <xsl:apply-templates/>
124       <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
125
126         <xsl:choose>
127           <xsl:when test="$make.index.markup != 0">
128             <fo:block wrap-option='no-wrap'
129                       white-space-collapse='false'
130                       xsl:use-attribute-sets="monospace.verbatim.properties"
131                       linefeed-treatment="preserve">
132               <xsl:call-template name="generate-index-markup">
133                 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
134               </xsl:call-template>
135             </fo:block>
136           </xsl:when>
137           <xsl:when test="indexentry|indexdiv/indexentry">
138             <xsl:apply-templates/>
139           </xsl:when>
140           <xsl:otherwise>
141             <xsl:call-template name="generate-index">
142               <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
143             </xsl:call-template>
144           </xsl:otherwise>
145         </xsl:choose>
146       </xsl:if>
147     </fo:flow>
148   </fo:page-sequence>
149  </xsl:if>
150 </xsl:template>
151
152 <xsl:template match="setindex">
153   <xsl:variable name="id">
154     <xsl:call-template name="object.id"/>
155   </xsl:variable>
156
157  <xsl:if test="$generate.index != 0">
158   <xsl:variable name="master-reference">
159     <xsl:call-template name="select.pagemaster">
160       <xsl:with-param name="pageclass">
161         <xsl:choose>
162           <xsl:when test="$make.index.markup != 0">body</xsl:when>
163           <xsl:otherwise>index</xsl:otherwise>
164         </xsl:choose>
165       </xsl:with-param>
166     </xsl:call-template>
167   </xsl:variable>
168
169   <fo:page-sequence hyphenate="{$hyphenate}"
170                     master-reference="{$master-reference}">
171     <xsl:attribute name="language">
172       <xsl:call-template name="l10n.language"/>
173     </xsl:attribute>
174     <xsl:attribute name="format">
175       <xsl:call-template name="page.number.format">
176         <xsl:with-param name="master-reference" select="$master-reference"/>
177       </xsl:call-template>
178     </xsl:attribute>
179
180     <xsl:attribute name="initial-page-number">
181       <xsl:call-template name="initial.page.number">
182         <xsl:with-param name="master-reference" select="$master-reference"/>
183       </xsl:call-template>
184     </xsl:attribute>
185
186     <xsl:attribute name="force-page-count">
187       <xsl:call-template name="force.page.count">
188         <xsl:with-param name="master-reference" select="$master-reference"/>
189       </xsl:call-template>
190     </xsl:attribute>
191
192     <xsl:attribute name="hyphenation-character">
193       <xsl:call-template name="gentext">
194         <xsl:with-param name="key" select="'hyphenation-character'"/>
195       </xsl:call-template>
196     </xsl:attribute>
197     <xsl:attribute name="hyphenation-push-character-count">
198       <xsl:call-template name="gentext">
199         <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
200       </xsl:call-template>
201     </xsl:attribute>
202     <xsl:attribute name="hyphenation-remain-character-count">
203       <xsl:call-template name="gentext">
204         <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
205       </xsl:call-template>
206     </xsl:attribute>
207
208     <xsl:apply-templates select="." mode="running.head.mode">
209       <xsl:with-param name="master-reference" select="$master-reference"/>
210     </xsl:apply-templates>
211     <xsl:apply-templates select="." mode="running.foot.mode">
212       <xsl:with-param name="master-reference" select="$master-reference"/>
213     </xsl:apply-templates>
214
215     <fo:flow flow-name="xsl-region-body">
216       <xsl:call-template name="set.flow.properties">
217         <xsl:with-param name="element" select="local-name(.)"/>
218         <xsl:with-param name="master-reference" select="$master-reference"/>
219       </xsl:call-template>
220
221       <fo:block id="{$id}">
222         <xsl:call-template name="setindex.titlepage"/>
223       </fo:block>
224       <xsl:apply-templates/>
225       <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
226
227         <xsl:choose>
228           <xsl:when test="$make.index.markup != 0">
229             <fo:block wrap-option='no-wrap'
230                       white-space-collapse='false'
231                       xsl:use-attribute-sets="monospace.verbatim.properties"
232                       linefeed-treatment="preserve">
233               <xsl:call-template name="generate-index-markup">
234                 <xsl:with-param name="scope" select="/"/>
235               </xsl:call-template>
236             </fo:block>
237           </xsl:when>
238           <xsl:when test="indexentry|indexdiv/indexentry">
239             <xsl:apply-templates/>
240           </xsl:when>
241           <xsl:otherwise>
242             <xsl:call-template name="generate-index">
243               <xsl:with-param name="scope" select="/"/>
244             </xsl:call-template>
245           </xsl:otherwise>
246         </xsl:choose>
247       </xsl:if>
248     </fo:flow>
249   </fo:page-sequence>
250  </xsl:if>
251 </xsl:template>
252
253 <xsl:template match="index/indexinfo"></xsl:template>
254 <xsl:template match="index/info"></xsl:template>
255 <xsl:template match="index/title"></xsl:template>
256 <xsl:template match="index/subtitle"></xsl:template>
257 <xsl:template match="index/titleabbrev"></xsl:template>
258
259 <!-- ==================================================================== -->
260
261 <xsl:template name="indexdiv.title">
262   <xsl:param name="title"/>
263   <xsl:param name="titlecontent"/>
264
265   <fo:block xsl:use-attribute-sets="index.div.title.properties">
266     <xsl:choose>
267       <xsl:when test="$title">
268         <xsl:apply-templates select="." mode="object.title.markup">
269           <xsl:with-param name="allow-anchors" select="1"/>
270         </xsl:apply-templates>
271       </xsl:when>
272       <xsl:otherwise>
273         <xsl:copy-of select="$titlecontent"/>
274       </xsl:otherwise>
275     </xsl:choose>
276   </fo:block>
277 </xsl:template>
278
279 <xsl:template match="indexdiv">
280   <fo:block>
281     <xsl:call-template name="indexdiv.titlepage"/>
282     <xsl:apply-templates/>
283   </fo:block>
284 </xsl:template>
285
286 <xsl:template match="indexdiv/title"/>
287 <xsl:template match="indexdiv/subtitle"/>
288 <xsl:template match="indexdiv/titleabbrev"/>
289
290 <!-- ==================================================================== -->
291
292 <!-- Text used for distiguishing between normal and significant entries -->
293 <xsl:variable name="significant.flag">.tnacifingis</xsl:variable>
294
295 <xsl:template match="indexterm" name="indexterm">
296   <!-- Temporal workaround for bug in AXF -->
297   <xsl:variable name="wrapper.name">
298     <xsl:choose>
299       <xsl:when test="$axf.extensions != 0 or $fop1.extensions != 0">
300         <xsl:call-template name="inline.or.block"/>
301       </xsl:when>
302       <xsl:otherwise>fo:wrapper</xsl:otherwise>
303     </xsl:choose>
304   </xsl:variable>
305
306   <xsl:element name="{$wrapper.name}">
307     <xsl:attribute name="id">
308       <xsl:call-template name="object.id"/>
309     </xsl:attribute>
310     <xsl:choose>
311       <xsl:when test="$xep.extensions != 0">
312         <xsl:attribute name="rx:key">
313           <xsl:value-of select="&primary;"/>
314           <xsl:if test="@significance='preferred'"><xsl:value-of select="$significant.flag"/></xsl:if>
315           <xsl:if test="secondary">
316             <xsl:text>, </xsl:text>
317             <xsl:value-of select="&secondary;"/>
318           </xsl:if>
319           <xsl:if test="tertiary">
320             <xsl:text>, </xsl:text>
321             <xsl:value-of select="&tertiary;"/>
322           </xsl:if>
323         </xsl:attribute>
324       </xsl:when>
325       <xsl:otherwise>
326         <xsl:comment>
327           <xsl:call-template name="comment-escape-string">
328             <xsl:with-param name="string">
329               <xsl:value-of select="primary"/>
330               <xsl:if test="secondary">
331                 <xsl:text>, </xsl:text>
332                 <xsl:value-of select="secondary"/>
333               </xsl:if>
334               <xsl:if test="tertiary">
335                 <xsl:text>, </xsl:text>
336                 <xsl:value-of select="tertiary"/>
337               </xsl:if>
338             </xsl:with-param>
339           </xsl:call-template>
340         </xsl:comment>
341       </xsl:otherwise>
342     </xsl:choose>
343   </xsl:element>
344 </xsl:template>
345
346 <xsl:template match="indexterm[@class='startofrange']">
347   <xsl:choose>
348     <xsl:when test="$xep.extensions != 0">
349       <rx:begin-index-range>
350         <xsl:call-template name="anchor"/>
351         <xsl:attribute name="rx:key">
352           <xsl:value-of select="&primary;"/>
353           <xsl:if test="@significance='preferred'"><xsl:value-of select="$significant.flag"/></xsl:if>
354           <xsl:if test="secondary">
355             <xsl:text>, </xsl:text>
356             <xsl:value-of select="&secondary;"/>
357           </xsl:if>
358           <xsl:if test="tertiary">
359             <xsl:text>, </xsl:text>
360             <xsl:value-of select="&tertiary;"/>
361           </xsl:if>
362         </xsl:attribute>
363       </rx:begin-index-range>
364     </xsl:when>
365     <xsl:otherwise>
366       <xsl:call-template name="indexterm"/>
367     </xsl:otherwise>
368   </xsl:choose>
369 </xsl:template>
370
371 <xsl:template match="indexterm[@class='endofrange']">
372   <xsl:choose>
373     <xsl:when test="$xep.extensions != 0">
374       <rx:end-index-range>
375         <xsl:attribute name="ref-id">
376           <xsl:value-of select="@startref"/>
377         </xsl:attribute>
378       </rx:end-index-range>
379     </xsl:when>
380     <xsl:otherwise>
381       <xsl:call-template name="indexterm"/>
382     </xsl:otherwise>
383   </xsl:choose>
384 </xsl:template>
385
386 <!-- ==================================================================== -->
387
388 <xsl:template match="indexentry">
389   <fo:block>
390     <!-- don't process 'seeie's from here -->
391     <xsl:apply-templates select="primaryie|secondaryie|tertiaryie|seealsoie"/>
392   </fo:block>
393 </xsl:template>
394
395 <xsl:template match="primaryie">
396   <fo:block>
397     <xsl:apply-templates/>
398     <xsl:if test="following-sibling::seeie">
399       <xsl:text> (</xsl:text>
400       <xsl:call-template name="gentext">
401         <xsl:with-param name="key" select="'see'"/>
402       </xsl:call-template>
403       <xsl:text> </xsl:text>
404       <xsl:apply-templates select="following-sibling::seeie"/>
405       <xsl:text>)</xsl:text>
406     </xsl:if>
407   </fo:block>
408 </xsl:template>
409
410 <xsl:template match="secondaryie">
411   <fo:block start-indent="1pc">
412     <xsl:apply-templates/>
413     <xsl:if test="following-sibling::seeie">
414       <xsl:text> (</xsl:text>
415       <xsl:call-template name="gentext">
416         <xsl:with-param name="key" select="'see'"/>
417       </xsl:call-template>
418       <xsl:text> </xsl:text>
419       <xsl:apply-templates select="following-sibling::seeie"/>
420       <xsl:text>)</xsl:text>
421     </xsl:if>
422   </fo:block>
423 </xsl:template>
424
425 <xsl:template match="tertiaryie">
426   <fo:block start-indent="2pc">
427     <xsl:apply-templates/>
428     <xsl:if test="following-sibling::seeie">
429       <xsl:text> (</xsl:text>
430       <xsl:call-template name="gentext">
431         <xsl:with-param name="key" select="'see'"/>
432       </xsl:call-template>
433       <xsl:text> </xsl:text>
434       <xsl:apply-templates select="following-sibling::seeie"/>
435       <xsl:text>)</xsl:text>
436     </xsl:if>
437   </fo:block>
438 </xsl:template>
439
440 <xsl:template match="seeie">
441   <fo:inline>
442     <xsl:apply-templates/>
443   </fo:inline>
444 </xsl:template>
445
446 <xsl:template match="seealsoie">
447   <fo:block>
448     <xsl:attribute name="start-indent">
449       <xsl:choose>
450         <xsl:when test="(preceding-sibling::tertiaryie |
451                          preceding-sibling::secondaryie)[last()]
452                          [self::tertiaryie]">3pc</xsl:when>
453         <xsl:when test="(preceding-sibling::tertiaryie |
454                          preceding-sibling::secondaryie)[last()]
455                          [self::secondaryie]">2pc</xsl:when>
456         <xsl:otherwise>1pc</xsl:otherwise>
457       </xsl:choose>
458     </xsl:attribute>
459     <xsl:text>(</xsl:text>
460     <xsl:call-template name="gentext">
461       <xsl:with-param name="key" select="'seealso'"/>
462     </xsl:call-template>
463     <xsl:text> </xsl:text>
464     <xsl:apply-templates/>
465     <xsl:text>)</xsl:text>
466   </fo:block>
467 </xsl:template>
468
469 <!-- Determines if an object should be inserted as an fo:inline
470      or an fo:block.  Used for indexterms -->
471 <xsl:template name="inline.or.block">
472   <xsl:param name="parentnode" select=".."/>
473
474   <xsl:variable name="parent" select="concat('|', local-name($parentnode), '|')"/>
475
476   <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|'"/>
477
478   <xsl:choose>
479     <xsl:when test="contains($block.parents, $parent)">fo:block</xsl:when>
480     <xsl:when test="$fop1.extensions != 0">fo:wrapper</xsl:when>
481     <xsl:otherwise>fo:inline</xsl:otherwise>
482   </xsl:choose>
483 </xsl:template>
484
485 </xsl:stylesheet>