autoidx-kosek.xsl 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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:i="urn:cz-kosek:functions:index" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:func="http://exslt.org/functions" xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService" xmlns:exslt="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" extension-element-prefixes="func exslt" exclude-result-prefixes="func exslt i l k" version="1.0">
  5. <!-- ********************************************************************
  6. $Id: autoidx-kosek.xsl 8725 2010-07-15 08:08:04Z kosek $
  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 "kosek" method contributed by Jirka Kosek. -->
  14. <xsl:include href="../common/autoidx-kosek.xsl"/>
  15. <xsl:template name="generate-kosek-index">
  16. <xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
  17. <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  18. <xsl:if test="contains($vendor, 'libxslt')">
  19. <xsl:message terminate="yes">
  20. <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
  21. <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
  22. </xsl:message>
  23. </xsl:if>
  24. <xsl:if test="contains($vendor, 'Saxonica')">
  25. <xsl:message terminate="yes">
  26. <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
  27. <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
  28. </xsl:message>
  29. </xsl:if>
  30. <xsl:if test="$exsl.node.set.available = 0">
  31. <xsl:message terminate="yes">
  32. <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
  33. <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
  34. <xsl:text>has it, or use a different index method.</xsl:text>
  35. </xsl:message>
  36. </xsl:if>
  37. <xsl:if test="not(function-available('i:group-index'))">
  38. <xsl:message terminate="yes">
  39. <xsl:text>ERROR: the 'kosek' index method requires the
  40. </xsl:text>
  41. <xsl:text>index extension functions be imported:
  42. </xsl:text>
  43. <xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
  44. </xsl:message>
  45. </xsl:if>
  46. <xsl:variable name="role">
  47. <xsl:if test="$index.on.role != 0">
  48. <xsl:value-of select="@role"/>
  49. </xsl:if>
  50. </xsl:variable>
  51. <xsl:variable name="type">
  52. <xsl:if test="$index.on.type != 0">
  53. <xsl:value-of select="@type"/>
  54. </xsl:if>
  55. </xsl:variable>
  56. <xsl:variable name="terms" select="//indexterm[count(.|key('group-code', i:group-index(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')]"/>
  57. <div class="index">
  58. <xsl:apply-templates select="$terms" mode="index-div-kosek">
  59. <xsl:with-param name="scope" select="$scope"/>
  60. <xsl:with-param name="role" select="$role"/>
  61. <xsl:with-param name="type" select="$type"/>
  62. <xsl:sort select="i:group-index(normalize-space(concat(primary/@sortas, &quot; &quot;, primary)))" data-type="number"/>
  63. </xsl:apply-templates>
  64. </div>
  65. </xsl:template>
  66. <xsl:template match="indexterm" mode="index-div-kosek">
  67. <xsl:param name="scope" select="."/>
  68. <xsl:param name="role" select="''"/>
  69. <xsl:param name="type" select="''"/>
  70. <xsl:variable name="key" select="i:group-index(normalize-space(concat(primary/@sortas, &quot; &quot;, primary)))"/>
  71. <xsl:variable name="lang">
  72. <xsl:call-template name="l10n.language"/>
  73. </xsl:variable>
  74. <xsl:if test="key('group-code', $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]">
  75. <div class="indexdiv">
  76. <h3>
  77. <xsl:value-of select="i:group-letter($key)"/>
  78. </h3>
  79. <dl>
  80. <xsl:apply-templates select="key('group-code', $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">
  81. <xsl:sort select="normalize-space(concat(primary/@sortas, &quot; &quot;, primary))" lang="{$lang}"/>
  82. <xsl:with-param name="scope" select="$scope"/>
  83. <xsl:with-param name="role" select="$role"/>
  84. <xsl:with-param name="type" select="$type"/>
  85. </xsl:apply-templates>
  86. </dl>
  87. </div>
  88. </xsl:if>
  89. </xsl:template>
  90. </xsl:stylesheet>