autoidx-kosek.xsl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?xml version="1.0"?>
  2. <!DOCTYPE xsl:stylesheet [
  3. <!ENTITY % common.entities SYSTEM "../common/entities.ent">
  4. %common.entities;
  5. ]>
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:i="urn:cz-kosek:functions:index"
  8. xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
  9. xmlns:func="http://exslt.org/functions"
  10. xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService"
  11. xmlns:exslt="http://exslt.org/common"
  12. extension-element-prefixes="func exslt"
  13. exclude-result-prefixes="func exslt i l k"
  14. version="1.0">
  15. <!-- ********************************************************************
  16. $Id: autoidx-kosek.xsl 8725 2010-07-15 08:08:04Z kosek $
  17. ********************************************************************
  18. This file is part of the XSL DocBook Stylesheet distribution.
  19. See ../README or http://docbook.sf.net/release/xsl/current/ for
  20. copyright and other information.
  21. ******************************************************************** -->
  22. <!-- ==================================================================== -->
  23. <!-- The "kosek" method contributed by Jirka Kosek. -->
  24. <xsl:include href="../common/autoidx-kosek.xsl"/>
  25. <xsl:template name="generate-kosek-index">
  26. <xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
  27. <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  28. <xsl:if test="contains($vendor, 'libxslt')">
  29. <xsl:message terminate="yes">
  30. <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
  31. <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
  32. </xsl:message>
  33. </xsl:if>
  34. <xsl:if test="contains($vendor, 'Saxonica')">
  35. <xsl:message terminate="yes">
  36. <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
  37. <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
  38. </xsl:message>
  39. </xsl:if>
  40. <xsl:if test="$exsl.node.set.available = 0">
  41. <xsl:message terminate="yes">
  42. <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
  43. <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
  44. <xsl:text>has it, or use a different index method.</xsl:text>
  45. </xsl:message>
  46. </xsl:if>
  47. <xsl:if test="not(function-available('i:group-index'))">
  48. <xsl:message terminate="yes">
  49. <xsl:text>ERROR: the 'kosek' index method requires the&#xA;</xsl:text>
  50. <xsl:text>index extension functions be imported:&#xA;</xsl:text>
  51. <xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
  52. </xsl:message>
  53. </xsl:if>
  54. <xsl:variable name="role">
  55. <xsl:if test="$index.on.role != 0">
  56. <xsl:value-of select="@role"/>
  57. </xsl:if>
  58. </xsl:variable>
  59. <xsl:variable name="type">
  60. <xsl:if test="$index.on.type != 0">
  61. <xsl:value-of select="@type"/>
  62. </xsl:if>
  63. </xsl:variable>
  64. <xsl:variable name="terms"
  65. select="//indexterm[count(.|key('group-code', i:group-index(&primary;))[&scope;][1]) = 1 and not(@class = 'endofrange')]"/>
  66. <div class="index">
  67. <xsl:apply-templates select="$terms" mode="index-div-kosek">
  68. <xsl:with-param name="scope" select="$scope"/>
  69. <xsl:with-param name="role" select="$role"/>
  70. <xsl:with-param name="type" select="$type"/>
  71. <xsl:sort select="i:group-index(&primary;)" data-type="number"/>
  72. </xsl:apply-templates>
  73. </div>
  74. </xsl:template>
  75. <xsl:template match="indexterm" mode="index-div-kosek">
  76. <xsl:param name="scope" select="."/>
  77. <xsl:param name="role" select="''"/>
  78. <xsl:param name="type" select="''"/>
  79. <xsl:variable name="key"
  80. select="i:group-index(&primary;)"/>
  81. <xsl:variable name="lang">
  82. <xsl:call-template name="l10n.language"/>
  83. </xsl:variable>
  84. <xsl:if test="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
  85. <div class="indexdiv">
  86. <h3>
  87. <xsl:value-of select="i:group-letter($key)"/>
  88. </h3>
  89. <dl>
  90. <xsl:apply-templates select="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1])=1]"
  91. mode="index-primary">
  92. <xsl:sort select="&primary;" lang="{$lang}"/>
  93. <xsl:with-param name="scope" select="$scope"/>
  94. <xsl:with-param name="role" select="$role"/>
  95. <xsl:with-param name="type" select="$type"/>
  96. </xsl:apply-templates>
  97. </dl>
  98. </div>
  99. </xsl:if>
  100. </xsl:template>
  101. </xsl:stylesheet>