This commit was manufactured by cvs2svn to create tag 'v5_1_1'.
[linux_from_scratch.git] / BOOK / stylesheets / print / lfs-index.xsl
blob63a014a826b1045e0534fc282c9a3ed08606890f
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 ]>
9 <!-- Version 0.9 - Manuel Canales Esparcia <macana@lfs-es.org> -->
11 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12 xmlns:fo="http://www.w3.org/1999/XSL/Format"
13 version="1.0">
15 <!--Title-->
16 <xsl:template match="index" mode="title.markup">
17 <xsl:param name="allow-anchors" select="0"/>
18 <xsl:text>Index of packages and important installed files</xsl:text>
19 </xsl:template>
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:text>Packages</xsl:text>
36 </xsl:when>
37 <xsl:when test="$divtitle = 'B'">
38 <xsl:text>Programs</xsl:text>
39 </xsl:when>
40 <xsl:when test="$divtitle = 'C'">
41 <xsl:text>Libraries</xsl:text>
42 </xsl:when>
43 <xsl:when test="$divtitle = 'D'">
44 <xsl:text>Scripts</xsl:text>
45 </xsl:when>
46 <xsl:when test="$divtitle = 'E'">
47 <xsl:text>Others</xsl:text>
48 </xsl:when>
49 <xsl:otherwise>
50 <xsl:value-of select="$divtitle"/>
51 </xsl:otherwise>
52 </xsl:choose>
53 </xsl:with-param>
54 </xsl:call-template>
55 </xsl:if>
56 <fo:block>
57 <xsl:apply-templates select="key('letter', $key)[&scope;]
58 [count(.|key('primary', &primary;)[&scope;][1])=1]"
59 mode="index-primary">
60 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
61 <xsl:with-param name="scope" select="$scope"/>
62 </xsl:apply-templates>
63 </fo:block>
64 </fo:block>
65 </xsl:if>
66 </xsl:template>
68 <!-- The separator -->
69 <xsl:template match="indexterm" mode="reference">
70 <xsl:param name="scope" select="."/>
71 <xsl:text>: </xsl:text>
72 <xsl:call-template name="reference">
73 <xsl:with-param name="zones" select="normalize-space(@zone)"/>
74 <xsl:with-param name="scope" select="$scope"/>
75 </xsl:call-template>
76 </xsl:template>
78 <!--Bookmarks-->
79 <xsl:template name="reference">
80 <xsl:param name="scope" select="."/>
81 <xsl:param name="zones"/>
82 <xsl:choose>
83 <xsl:when test="contains($zones, ' ')">
84 <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
85 <xsl:variable name="zone2" select="substring-after($zones, ' ')"/>
86 <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
87 <xsl:variable name="target2" select="key('id', $zone2)[&scope;]"/>
88 <xsl:variable name="id">
89 <xsl:call-template name="object.id">
90 <xsl:with-param name="object" select="$target[1]"/>
91 </xsl:call-template>
92 </xsl:variable>
93 <xsl:variable name="id2">
94 <xsl:call-template name="object.id">
95 <xsl:with-param name="object" select="$target2[1]"/>
96 </xsl:call-template>
97 </xsl:variable>
98 <fo:basic-link internal-destination="{$id}">
99 <xsl:apply-templates select="$target" mode="page.citation">
100 <xsl:with-param name="id" select="$id"/>
101 </xsl:apply-templates>
102 </fo:basic-link>
103 <xsl:text> , </xsl:text>
104 <fo:basic-link internal-destination="{$id2}">
105 <xsl:apply-templates select="$target2" mode="page.citation">
106 <xsl:with-param name="id" select="$id2"/>
107 </xsl:apply-templates>
108 </fo:basic-link>
109 </xsl:when>
110 <xsl:otherwise>
111 <xsl:variable name="zone" select="$zones"/>
112 <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
113 <xsl:variable name="id">
114 <xsl:call-template name="object.id">
115 <xsl:with-param name="object" select="$target[1]"/>
116 </xsl:call-template>
117 </xsl:variable>
118 <fo:basic-link internal-destination="{$id}">
119 <xsl:apply-templates select="$target" mode="page.citation">
120 <xsl:with-param name="id" select="$id"/>
121 </xsl:apply-templates>
122 </fo:basic-link>
123 </xsl:otherwise>
124 </xsl:choose>
125 </xsl:template>
127 </xsl:stylesheet>