Subversion Repositories svn LFS-FR

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7156 jlepiller 1
<?xml version="1.0"?>
2
<!DOCTYPE xsl:stylesheet [
3
 
4
<!ENTITY primary   'normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = ""]))'>
5
<!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = ""]))'>
6
<!ENTITY tertiary  'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = ""]))'>
7
 
8
<!ENTITY sep '" "'>
9
<!-- Documents using the kimber index method must have a lang attribute -->
10
<!-- Only one of these should be present in the entity -->
11
<!ENTITY lang 'concat(/*/@lang, /*/@xml:lang)'>
12
 
13
<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())
14
                and ($role = @role or $type = @type or
15
                (string-length($role) = 0 and string-length($type) = 0))'>
16
]>
17
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
19
                xmlns:k="java:com.isogen.saxoni18n.Saxoni18nService"
20
                exclude-result-prefixes="k"
21
                version="1.0">
22
 
23
<!-- ********************************************************************
24
     $Id: autoidx-kimber.xsl 6840 2007-07-07 10:25:55Z manuel $
25
     ********************************************************************
26
 
27
     This file is part of the DocBook XSL Stylesheet distribution.
28
     See ../README or http://docbook.sf.net/ for copyright
29
     copyright and other information.
30
 
31
     ******************************************************************** -->
32
 
33
<!-- ==================================================================== -->
34
<!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen.  -->
35
<!-- ==================================================================== -->
36
<!--   *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 ***             -->
37
<!-- ==================================================================== -->
38
 
39
<xsl:include href="../common/autoidx-kimber.xsl"/>
40
 
41
<!-- Java sort apparently works only on lang part, not country -->
42
<xsl:param name="sort.lang">
43
  <xsl:choose>
44
    <xsl:when test="contains(&lang;, '-')">
45
      <xsl:value-of select="substring-before(&lang;, '-')"/>
46
    </xsl:when>
47
    <xsl:when test="contains(&lang;, '_')">
48
      <xsl:value-of select="substring-before(&lang;, '_')"/>
49
    </xsl:when>
50
    <xsl:otherwise>
51
      <xsl:value-of select="&lang;"/>
52
    </xsl:otherwise>
53
  </xsl:choose>
54
</xsl:param>
55
 
56
<xsl:template name="generate-kimber-index">
57
  <xsl:param name="scope" select="NOTANODE"/>
58
 
59
  <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
60
  <xsl:if test="not(contains($vendor, 'SAXON '))">
61
    <xsl:message terminate="yes">
62
      <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
63
      <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
64
    </xsl:message>
65
  </xsl:if>
66
 
67
  <xsl:if test="not(function-available('k:getIndexGroupKey'))">
68
    <xsl:message terminate="yes">
69
      <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
70
      <xsl:text>Innodata Isogen &#x0A;Java extensions for </xsl:text>
71
      <xsl:text>internationalized indexes. &#x0A;Install those </xsl:text>
72
      <xsl:text>extensions, or use a different index method.&#x0A;</xsl:text>
73
      <xsl:text>For more information, see:&#x0A;</xsl:text>
74
      <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
75
    </xsl:message>
76
  </xsl:if>
77
 
78
  <xsl:variable name="role">
79
    <xsl:if test="$index.on.role != 0">
80
      <xsl:value-of select="@role"/>
81
    </xsl:if>
82
  </xsl:variable>
83
 
84
  <xsl:variable name="type">
85
    <xsl:if test="$index.on.type != 0">
86
      <xsl:value-of select="@type"/>
87
    </xsl:if>
88
  </xsl:variable>
89
 
90
  <xsl:variable name="terms"
91
                select="//indexterm[count(.|key('k-group',
92
                   k:getIndexGroupKey(&lang;, &primary;))
93
                   [&scope;][1]) = 1
94
                   and not(@class = 'endofrange')]"/>
95
 
96
  <xsl:variable name="alphabetical"
97
                select="$terms[not(starts-with(
98
                k:getIndexGroupKey(&lang;, &primary;),
99
                '#NUMERIC'
100
                ))]"/>
101
 
102
  <xsl:variable name="others"
103
                select="$terms[starts-with(
104
                k:getIndexGroupKey(&lang;, &primary;),
105
                '#NUMERIC'
106
                )]"/>
107
 
108
  <fo:block>
109
    <xsl:if test="$others">
110
      <xsl:call-template name="indexdiv.title">
111
        <xsl:with-param name="titlecontent">
112
          <xsl:call-template name="gentext">
113
            <xsl:with-param name="key" select="'index symbols'"/>
114
          </xsl:call-template>
115
        </xsl:with-param>
116
      </xsl:call-template>
117
 
118
      <fo:block>
119
        <xsl:apply-templates select="$others"
120
                             mode="index-symbol-div">
121
          <xsl:with-param name="scope" select="$scope"/>
122
          <xsl:with-param name="role" select="$role"/>
123
          <xsl:with-param name="type" select="$type"/>
124
          <xsl:sort lang="{$sort.lang}"
125
              select="k:getIndexGroupSortKey(&lang;,
126
                      k:getIndexGroupKey(&lang;, &primary;))"/>
127
        </xsl:apply-templates>
128
      </fo:block>
129
    </xsl:if>
130
 
131
    <xsl:apply-templates select="$alphabetical"
132
                         mode="index-div-kimber">
133
      <xsl:with-param name="scope" select="$scope"/>
134
      <xsl:with-param name="role" select="$role"/>
135
      <xsl:with-param name="type" select="$type"/>
136
      <xsl:sort lang="{$sort.lang}"
137
             select="k:getIndexGroupSortKey(&lang;,
138
                     k:getIndexGroupKey(&lang;, &primary;))"/>
139
    </xsl:apply-templates>
140
  </fo:block>
141
 
142
</xsl:template>
143
 
144
<xsl:template match="indexterm" mode="index-div-kimber">
145
  <xsl:param name="scope" select="."/>
146
  <xsl:param name="role" select="''"/>
147
  <xsl:param name="type" select="''"/>
148
 
149
  <xsl:variable name="key"
150
          select="k:getIndexGroupKey(&lang;, &primary;)"/>
151
 
152
  <xsl:variable name="label"
153
          select="k:getIndexGroupLabel(&lang;, $key)"/>
154
 
155
  <xsl:if test="key('k-group', $key)[&scope;]
156
                [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
157
    <fo:block>
158
      <xsl:call-template name="indexdiv.title">
159
        <xsl:with-param name="titlecontent">
160
          <xsl:value-of select="$label"/>
161
        </xsl:with-param>
162
      </xsl:call-template>
163
      <fo:block>
164
        <xsl:apply-templates select="key('k-group', $key)[&scope;]
165
                            [count(.|key('primary', &primary;)[&scope;]
166
                            [1])=1]"
167
                             mode="index-primary">
168
          <xsl:sort select="&primary;" lang="{$sort.lang}"/>
169
          <xsl:with-param name="scope" select="$scope"/>
170
          <xsl:with-param name="role" select="$role"/>
171
          <xsl:with-param name="type" select="$type"/>
172
        </xsl:apply-templates>
173
      </fo:block>
174
    </fo:block>
175
  </xsl:if>
176
</xsl:template>
177
 
178
</xsl:stylesheet>