source: BOOK/stylesheets/pdf/lfs-index.xsl@ 0d0fc28

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 0d0fc28 was 3f8be484, checked in by Jim Gifford <clfs@…>, 19 years ago

r627@server (orig r625): jim | 2005-10-31 12:59:34 -0800
Import of Cross-LFS Book

  • Property mode set to 100644
File size: 5.9 KB
Line 
1<?xml version='1.0' encoding='ISO-8859-1'?>
2<!DOCTYPE xsl:stylesheet [
3<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
4<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
5<!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
6<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())'>
7]>
8
9<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:fo="http://www.w3.org/1999/XSL/Format"
11 version="1.0">
12
13 <!--Title-->
14 <xsl:template match="index" mode="title.markup">
15 <xsl:param name="allow-anchors" select="0"/>
16 <xsl:call-template name="gentext">
17 <xsl:with-param name="key">Index</xsl:with-param>
18 </xsl:call-template>
19 </xsl:template>
20
21 <!-- Divisions-->
22 <xsl:template match="indexterm" mode="index-div">
23 <xsl:param name="scope" select="."/>
24 <xsl:variable name="key"
25 select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
26 <xsl:variable name="divtitle" select="translate($key, &lowercase;, &uppercase;)"/>
27 <xsl:if test="key('letter', $key)[&scope;]
28 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
29 <fo:block>
30 <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
31 <xsl:call-template name="indexdiv.title">
32 <xsl:with-param name="titlecontent">
33 <xsl:choose>
34 <xsl:when test="$divtitle = 'A'">
35 <xsl:call-template name="gentext">
36 <xsl:with-param name="key">Packages</xsl:with-param>
37 </xsl:call-template>
38 </xsl:when>
39 <xsl:when test="$divtitle = 'B'">
40 <xsl:call-template name="gentext">
41 <xsl:with-param name="key">Programs</xsl:with-param>
42 </xsl:call-template>
43 </xsl:when>
44 <xsl:when test="$divtitle = 'C'">
45 <xsl:call-template name="gentext">
46 <xsl:with-param name="key">Libraries</xsl:with-param>
47 </xsl:call-template>
48 </xsl:when>
49 <xsl:when test="$divtitle = 'D'">
50 <xsl:call-template name="gentext">
51 <xsl:with-param name="key">Scripts</xsl:with-param>
52 </xsl:call-template>
53 </xsl:when>
54 <xsl:when test="$divtitle = 'E'">
55 <xsl:call-template name="gentext">
56 <xsl:with-param name="key">Others</xsl:with-param>
57 </xsl:call-template>
58 </xsl:when>
59 <xsl:otherwise>
60 <xsl:value-of select="$divtitle"/>
61 </xsl:otherwise>
62 </xsl:choose>
63 </xsl:with-param>
64 </xsl:call-template>
65 </xsl:if>
66 <fo:block>
67 <xsl:apply-templates select="key('letter', $key)[&scope;]
68 [count(.|key('primary', &primary;)[&scope;][1])=1]"
69 mode="index-primary">
70 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
71 <xsl:with-param name="scope" select="$scope"/>
72 </xsl:apply-templates>
73 </fo:block>
74 </fo:block>
75 </xsl:if>
76 </xsl:template>
77
78 <!-- The separator -->
79 <xsl:template match="indexterm" mode="reference">
80 <xsl:param name="scope" select="."/>
81 <xsl:text>: </xsl:text>
82 <xsl:call-template name="reference">
83 <xsl:with-param name="zones" select="normalize-space(@zone)"/>
84 <xsl:with-param name="scope" select="$scope"/>
85 </xsl:call-template>
86 </xsl:template>
87
88 <!--Bookmarks-->
89 <xsl:template name="reference">
90 <xsl:param name="scope" select="."/>
91 <xsl:param name="zones"/>
92 <xsl:choose>
93 <xsl:when test="contains($zones, ' ')">
94 <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
95 <xsl:variable name="zone2" select="substring-after($zones, ' ')"/>
96 <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
97 <xsl:variable name="target2" select="key('id', $zone2)[&scope;]"/>
98 <xsl:variable name="id">
99 <xsl:call-template name="object.id">
100 <xsl:with-param name="object" select="$target[1]"/>
101 </xsl:call-template>
102 </xsl:variable>
103 <xsl:variable name="id2">
104 <xsl:call-template name="object.id">
105 <xsl:with-param name="object" select="$target2[1]"/>
106 </xsl:call-template>
107 </xsl:variable>
108 <fo:basic-link internal-destination="{$id}">
109 <xsl:apply-templates select="$target" mode="page.citation">
110 <xsl:with-param name="id" select="$id"/>
111 </xsl:apply-templates>
112 </fo:basic-link>
113 <xsl:text> , </xsl:text>
114 <fo:basic-link internal-destination="{$id2}">
115 <xsl:apply-templates select="$target2" mode="page.citation">
116 <xsl:with-param name="id" select="$id2"/>
117 </xsl:apply-templates>
118 </fo:basic-link>
119 </xsl:when>
120 <xsl:otherwise>
121 <xsl:variable name="zone" select="$zones"/>
122 <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
123 <xsl:variable name="id">
124 <xsl:call-template name="object.id">
125 <xsl:with-param name="object" select="$target[1]"/>
126 </xsl:call-template>
127 </xsl:variable>
128 <fo:basic-link internal-destination="{$id}">
129 <xsl:apply-templates select="$target" mode="page.citation">
130 <xsl:with-param name="id" select="$id"/>
131 </xsl:apply-templates>
132 </fo:basic-link>
133 </xsl:otherwise>
134 </xsl:choose>
135 </xsl:template>
136
137 <!-- Page number in Index-->
138 <xsl:template match="*" mode="page.citation">
139 <xsl:param name="id" select="'???'"/>
140 <fo:inline keep-together.within-line="always">
141 <!--<xsl:text>[p</xsl:text>-->
142 <fo:page-number-citation ref-id="{$id}"/>
143 <!--<xsl:text>]</xsl:text>-->
144 </fo:inline>
145 </xsl:template>
146
147</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.