autoidx-kosek.xsl 5.5 KB

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