autoidx-kimber.xsl 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><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">
  2. <!-- ********************************************************************
  3. $Id$
  4. ********************************************************************
  5. This file is part of the XSL DocBook Stylesheet distribution.
  6. See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  7. and other information.
  8. ******************************************************************** -->
  9. <!-- ==================================================================== -->
  10. <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen. -->
  11. <!-- ==================================================================== -->
  12. <!-- *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 *** -->
  13. <!-- ==================================================================== -->
  14. <xsl:include href="../common/autoidx-kimber.xsl"/>
  15. <!-- Java sort apparently works only on lang part, not country -->
  16. <xsl:param name="sort.lang">
  17. <xsl:choose>
  18. <xsl:when test="contains(concat(/*/@lang, /*/@xml:lang), '-')">
  19. <xsl:value-of select="substring-before(concat(/*/@lang, /*/@xml:lang), '-')"/>
  20. </xsl:when>
  21. <xsl:when test="contains(concat(/*/@lang, /*/@xml:lang), '_')">
  22. <xsl:value-of select="substring-before(concat(/*/@lang, /*/@xml:lang), '_')"/>
  23. </xsl:when>
  24. <xsl:otherwise>
  25. <xsl:value-of select="concat(/*/@lang, /*/@xml:lang)"/>
  26. </xsl:otherwise>
  27. </xsl:choose>
  28. </xsl:param>
  29. <xsl:template name="generate-kimber-index">
  30. <xsl:param name="scope" select="NOTANODE"/>
  31. <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  32. <xsl:if test="not(contains($vendor, 'SAXON '))">
  33. <xsl:message terminate="yes">
  34. <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
  35. <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
  36. </xsl:message>
  37. </xsl:if>
  38. <xsl:if test="not(function-available('k:getIndexGroupKey'))">
  39. <xsl:message terminate="yes">
  40. <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
  41. <xsl:text>Innodata Isogen
  42. Java extensions for </xsl:text>
  43. <xsl:text>internationalized indexes.
  44. Install those </xsl:text>
  45. <xsl:text>extensions, or use a different index method.
  46. </xsl:text>
  47. <xsl:text>For more information, see:
  48. </xsl:text>
  49. <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
  50. </xsl:message>
  51. </xsl:if>
  52. <xsl:variable name="role">
  53. <xsl:if test="$index.on.role != 0">
  54. <xsl:value-of select="@role"/>
  55. </xsl:if>
  56. </xsl:variable>
  57. <xsl:variable name="type">
  58. <xsl:if test="$index.on.type != 0">
  59. <xsl:value-of select="@type"/>
  60. </xsl:if>
  61. </xsl:variable>
  62. <xsl:variable name="terms" select="//indexterm[count(.|key('k-group', k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = &#34;&#34;]))))[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')]"/>
  63. <xsl:variable name="alphabetical" select="$terms[not(starts-with( k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = &#34;&#34;]))), '#NUMERIC' ))]"/>
  64. <xsl:variable name="others" select="$terms[starts-with( k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = &#34;&#34;]))), '#NUMERIC' )]"/>
  65. <div class="index">
  66. <xsl:if test="$others">
  67. <div class="indexdev">
  68. <h3>
  69. <xsl:call-template name="gentext">
  70. <xsl:with-param name="key" select="'index symbols'"/>
  71. </xsl:call-template>
  72. </h3>
  73. <dl>
  74. <xsl:apply-templates select="$others" mode="index-symbol-div">
  75. <xsl:with-param name="scope" select="$scope"/>
  76. <xsl:with-param name="role" select="$role"/>
  77. <xsl:with-param name="type" select="$type"/>
  78. <xsl:sort lang="{$sort.lang}" select="k:getIndexGroupSortKey(concat(/*/@lang, /*/@xml:lang), k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = &#34;&#34;]))))"/>
  79. </xsl:apply-templates>
  80. </dl>
  81. </div>
  82. </xsl:if>
  83. <xsl:apply-templates select="$alphabetical" mode="index-div-kimber">
  84. <xsl:with-param name="scope" select="$scope"/>
  85. <xsl:with-param name="role" select="$role"/>
  86. <xsl:with-param name="type" select="$type"/>
  87. <xsl:sort lang="{$sort.lang}" select="k:getIndexGroupSortKey(concat(/*/@lang, /*/@xml:lang), k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = &#34;&#34;]))))"/>
  88. </xsl:apply-templates>
  89. </div>
  90. </xsl:template>
  91. <xsl:template match="indexterm" mode="index-div-kimber">
  92. <xsl:param name="scope" select="."/>
  93. <xsl:param name="role" select="''"/>
  94. <xsl:param name="type" select="''"/>
  95. <xsl:variable name="key" select="k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = &#34;&#34;])))"/>
  96. <xsl:variable name="label" select="k:getIndexGroupLabel(concat(/*/@lang, /*/@xml:lang), $key)"/>
  97. <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[not(@sortas) or @sortas = &#34;&#34;])))[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]">
  98. <div class="indexdiv">
  99. <h3>
  100. <xsl:value-of select="$label"/>
  101. </h3>
  102. <dl>
  103. <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[not(@sortas) or @sortas = &#34;&#34;])))[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">
  104. <xsl:sort select="normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = &#34;&#34;]))" lang="{$sort.lang}"/>
  105. <xsl:with-param name="scope" select="$scope"/>
  106. <xsl:with-param name="role" select="$role"/>
  107. <xsl:with-param name="type" select="$type"/>
  108. </xsl:apply-templates>
  109. </dl>
  110. </div>
  111. </xsl:if>
  112. </xsl:template>
  113. </xsl:stylesheet>