1 <?xml version="1.0" encoding="ASCII"?>
 
   2 <!--This file was created automatically by html2xhtml-->
 
   3 <!--from the HTML stylesheets.-->
 
   4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="k" version="1.0">
 
   6 <!-- ********************************************************************
 
   7      $Id: autoidx-kimber.xsl 8729 2010-07-15 16:43:56Z bobstayton $
 
   8      ********************************************************************
 
  10      This file is part of the XSL DocBook Stylesheet distribution.
 
  11      See ../README or http://docbook.sf.net/release/xsl/current/ for
 
  12      copyright and other information.
 
  14      ******************************************************************** -->
 
  16 <!-- ==================================================================== -->
 
  17 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen.  -->
 
  18 <!-- ==================================================================== -->
 
  19 <!--   *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 ***             -->
 
  20 <!-- ==================================================================== -->
 
  23 <xsl:include href="../common/autoidx-kimber.xsl"/>
 
  25 <!-- Java sort apparently works only on lang part, not country -->
 
  26 <xsl:param name="sort.lang">
 
  28     <xsl:when test="contains(concat(/*/@lang, /*/@xml:lang), '-')">
 
  29       <xsl:value-of select="substring-before(concat(/*/@lang, /*/@xml:lang), '-')"/>
 
  31     <xsl:when test="contains(concat(/*/@lang, /*/@xml:lang), '_')">
 
  32       <xsl:value-of select="substring-before(concat(/*/@lang, /*/@xml:lang), '_')"/>
 
  35       <xsl:value-of select="concat(/*/@lang, /*/@xml:lang)"/>
 
  40 <xsl:template name="generate-kimber-index">
 
  41   <xsl:param name="scope" select="NOTANODE"/>
 
  43   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
 
  44   <xsl:if test="not(contains($vendor, 'SAXON '))">
 
  45     <xsl:message terminate="yes">
 
  46       <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
 
  47       <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
 
  51   <xsl:if test="not(function-available('k:getIndexGroupKey'))">
 
  52     <xsl:message terminate="yes">
 
  53       <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
 
  54       <xsl:text>Innodata Isogen 
 
  55 Java extensions for </xsl:text>
 
  56       <xsl:text>internationalized indexes. 
 
  57 Install those </xsl:text>
 
  58       <xsl:text>extensions, or use a different index method.
 
  60       <xsl:text>For more information, see:
 
  62       <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
 
  66   <xsl:variable name="role">
 
  67     <xsl:if test="$index.on.role != 0">
 
  68       <xsl:value-of select="@role"/>
 
  72   <xsl:variable name="type">
 
  73     <xsl:if test="$index.on.type != 0">
 
  74       <xsl:value-of select="@type"/>
 
  78   <xsl:variable name="terms" select="//indexterm[count(.|key('k-group', k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, " ", primary))))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]) = 1 and not(@class = 'endofrange')]"/>
 
  80   <xsl:variable name="alphabetical" select="$terms[not(starts-with(                 k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, " ", primary))),                 '#NUMERIC'                 ))]"/>
 
  82   <xsl:variable name="others" select="$terms[starts-with(                 k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, " ", primary))),                 '#NUMERIC'                 )]"/>
 
  85     <xsl:if test="$others">
 
  86       <div class="indexdev">
 
  88           <xsl:call-template name="gentext">
 
  89             <xsl:with-param name="key" select="'index symbols'"/>
 
  93           <xsl:apply-templates select="$others" mode="index-symbol-div">
 
  94             <xsl:with-param name="scope" select="$scope"/>
 
  95             <xsl:with-param name="role" select="$role"/>
 
  96             <xsl:with-param name="type" select="$type"/>
 
  97             <xsl:sort lang="{$sort.lang}" select="k:getIndexGroupSortKey(concat(/*/@lang, /*/@xml:lang),                         k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, " ", primary))))"/>
 
  98           </xsl:apply-templates>
 
 103     <xsl:apply-templates select="$alphabetical" mode="index-div-kimber">
 
 104       <xsl:with-param name="scope" select="$scope"/>
 
 105       <xsl:with-param name="role" select="$role"/>
 
 106       <xsl:with-param name="type" select="$type"/>
 
 107       <xsl:sort lang="{$sort.lang}" select="k:getIndexGroupSortKey(concat(/*/@lang, /*/@xml:lang),                      k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, " ", primary))))"/>
 
 108     </xsl:apply-templates>
 
 113 <xsl:template match="indexterm" mode="index-div-kimber">
 
 114   <xsl:param name="scope" select="."/>
 
 115   <xsl:param name="role" select="''"/>
 
 116   <xsl:param name="type" select="''"/>
 
 118   <xsl:variable name="key" select="k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, " ", primary)))"/>
 
 120   <xsl:variable name="label" select="k:getIndexGroupLabel(concat(/*/@lang, /*/@xml:lang), $key)"/>
 
 122   <xsl:if test="key('k-group', $label)[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][count(.|key('primary', normalize-space(concat(primary/@sortas, " ", primary)))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]) = 1]">
 
 123     <div class="indexdiv">
 
 125         <xsl:value-of select="$label"/>
 
 128         <xsl:apply-templates select="key('k-group', $key)[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))]                             [count(.|key('primary', normalize-space(concat(primary/@sortas, " ", primary)))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))]                             [1])=1]" mode="index-primary">
 
 129           <xsl:sort select="normalize-space(concat(primary/@sortas, " ", primary))" lang="{$sort.lang}"/>
 
 130           <xsl:with-param name="scope" select="$scope"/>
 
 131           <xsl:with-param name="role" select="$role"/>
 
 132           <xsl:with-param name="type" select="$type"/>
 
 133         </xsl:apply-templates>