autoidx-kimber.xsl 7.1 KB

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