source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/autoidx-kosek.xsl@ eb10cc08

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

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 5.8 KB
RevLine 
[f8c4e94]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
12<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())
13 and ($role = @role or $type = @type or
14 (string-length($role) = 0 and string-length($type) = 0))'>
15]>
16<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17 xmlns:fo="http://www.w3.org/1999/XSL/Format"
18 xmlns:rx="http://www.renderx.com/XSL/Extensions"
19 xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
20 xmlns:i="urn:cz-kosek:functions:index"
21 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
22 xmlns:func="http://exslt.org/functions"
23 xmlns:exslt="http://exslt.org/common"
24 extension-element-prefixes="func exslt"
25 exclude-result-prefixes="func exslt i l"
26 version="1.0">
27
28<!-- ********************************************************************
29 $Id$
30 ********************************************************************
31
32 This file is part of the DocBook XSL Stylesheet distribution.
33 See ../README or http://docbook.sf.net/ for copyright
34 copyright and other information.
35
36 ******************************************************************** -->
37
38<!-- ==================================================================== -->
39<!-- The "kosek" method contributed by Jirka Kosek. -->
40
41<xsl:include href="../common/autoidx-kosek.xsl"/>
42
43<xsl:template name="generate-kosek-index">
44 <xsl:param name="scope" select="NOTANODE"/>
45
46 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
47 <xsl:if test="contains($vendor, 'libxslt')">
48 <xsl:message terminate="yes">
49 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
50 <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
51 </xsl:message>
52 </xsl:if>
53
54 <xsl:if test="contains($vendor, 'Saxonica')">
55 <xsl:message terminate="yes">
56 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
57 <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
58 </xsl:message>
59 </xsl:if>
60
61
62 <xsl:if test="not(function-available('exslt:node-set') or
63 function-available('exslt:nodeSet'))">
64 <xsl:message terminate="yes">
65 <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
66 <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
67 <xsl:text>has it, or use a different index method.</xsl:text>
68 </xsl:message>
69 </xsl:if>
70
71 <xsl:if test="not(function-available('i:group-index'))">
72 <xsl:message terminate="yes">
73 <xsl:text>ERROR: the 'kosek' index method requires the&#xA;</xsl:text>
74 <xsl:text>index extension functions be imported:&#xA;</xsl:text>
75 <xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
76 </xsl:message>
77 </xsl:if>
78
79 <xsl:variable name="role">
80 <xsl:if test="$index.on.role != 0">
81 <xsl:value-of select="@role"/>
82 </xsl:if>
83 </xsl:variable>
84
85 <xsl:variable name="type">
86 <xsl:if test="$index.on.type != 0">
87 <xsl:value-of select="@type"/>
88 </xsl:if>
89 </xsl:variable>
90
91 <xsl:variable name="terms"
92 select="//indexterm[count(.|key('group-code',
93 i:group-index(&primary;))
94 [&scope;][1]) = 1
95 and not(@class = 'endofrange')]"/>
96 <fo:block>
97 <xsl:apply-templates select="$terms" mode="index-div-kosek">
98 <xsl:with-param name="scope" select="$scope"/>
99 <xsl:with-param name="role" select="$role"/>
100 <xsl:with-param name="type" select="$type"/>
101 <xsl:sort select="i:group-index(&primary;)" data-type="number"/>
102 </xsl:apply-templates>
103 </fo:block>
104</xsl:template>
105
106<xsl:template match="indexterm" mode="index-div-kosek">
107 <xsl:param name="scope" select="."/>
108 <xsl:param name="role" select="''"/>
109 <xsl:param name="type" select="''"/>
110
111 <xsl:variable name="key"
112 select="i:group-index(&primary;)"/>
113
114 <xsl:variable name="lang">
115 <xsl:call-template name="l10n.language"/>
116 </xsl:variable>
117
118 <xsl:if test="key('group-code', $key)[&scope;]
119 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
120 <fo:block>
121 <xsl:call-template name="indexdiv.title">
122 <xsl:with-param name="titlecontent">
123 <xsl:choose>
124 <xsl:when test="$key = 0">
125 <xsl:call-template name="gentext">
126 <xsl:with-param name="key" select="'index symbols'"/>
127 </xsl:call-template>
128 </xsl:when>
129 <xsl:otherwise>
130 <xsl:value-of select="i:group-letter($key)"/>
131 </xsl:otherwise>
132 </xsl:choose>
133 </xsl:with-param>
134 </xsl:call-template>
135 <fo:block>
136 <xsl:apply-templates select="key('group-code', $key)[&scope;]
137 [count(.|key('primary', &primary;)
138 [&scope;][1])=1]"
139 mode="index-primary">
140 <xsl:sort select="&primary;" lang="{$lang}"/>
141 <xsl:with-param name="scope" select="$scope"/>
142 <xsl:with-param name="role" select="$role"/>
143 <xsl:with-param name="type" select="$type"/>
144 </xsl:apply-templates>
145 </fo:block>
146 </fo:block>
147 </xsl:if>
148</xsl:template>
149
150</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.