index.xsl 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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="http://www.w3.org/1999/xhtml" version="1.0">
  5. <!-- ********************************************************************
  6. $Id$
  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. <xsl:template match="index">
  14. <!-- some implementations use completely empty index tags to indicate -->
  15. <!-- where an automatically generated index should be inserted. so -->
  16. <!-- if the index is completely empty, skip it. Unless generate.index -->
  17. <!-- is non-zero, in which case, this is where the automatically -->
  18. <!-- generated index should go. -->
  19. <xsl:call-template name="id.warning"/>
  20. <xsl:if test="count(*)&gt;0 or $generate.index != '0'">
  21. <div>
  22. <xsl:apply-templates select="." mode="class.attribute"/>
  23. <xsl:if test="$generate.id.attributes != 0">
  24. <xsl:attribute name="id">
  25. <xsl:call-template name="object.id"/>
  26. </xsl:attribute>
  27. </xsl:if>
  28. <xsl:call-template name="index.titlepage"/>
  29. <xsl:choose>
  30. <xsl:when test="indexdiv">
  31. <xsl:apply-templates/>
  32. </xsl:when>
  33. <xsl:otherwise>
  34. <xsl:apply-templates select="*[not(self::indexentry)]"/>
  35. <!-- Because it's actually valid for Index to have neither any -->
  36. <!-- Indexdivs nor any Indexentries, we need to check and make -->
  37. <!-- sure that at least one Indexentry exists, and generate a -->
  38. <!-- wrapper dl if there is at least one; otherwise, do nothing. -->
  39. <xsl:if test="indexentry">
  40. <!-- The indexentry template assumes a parent dl wrapper has -->
  41. <!-- been generated; for Indexes that have Indexdivs, the dl -->
  42. <!-- wrapper is generated by the indexdiv template; however, -->
  43. <!-- for Indexes that lack Indexdivs, if we don't generate a -->
  44. <!-- dl here, HTML output will not be valid. -->
  45. <dl>
  46. <xsl:apply-templates select="indexentry"/>
  47. </dl>
  48. </xsl:if>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
  52. <xsl:call-template name="generate-index">
  53. <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
  54. </xsl:call-template>
  55. </xsl:if>
  56. <xsl:if test="not(parent::article)">
  57. <xsl:call-template name="process.footnotes"/>
  58. </xsl:if>
  59. </div>
  60. </xsl:if>
  61. </xsl:template>
  62. <xsl:template match="setindex">
  63. <!-- some implementations use completely empty index tags to indicate -->
  64. <!-- where an automatically generated index should be inserted. so -->
  65. <!-- if the index is completely empty, skip it. Unless generate.index -->
  66. <!-- is non-zero, in which case, this is where the automatically -->
  67. <!-- generated index should go. -->
  68. <xsl:call-template name="id.warning"/>
  69. <xsl:if test="count(*)&gt;0 or $generate.index != '0'">
  70. <div>
  71. <xsl:apply-templates select="." mode="class.attribute"/>
  72. <xsl:if test="$generate.id.attributes != 0">
  73. <xsl:attribute name="id">
  74. <xsl:call-template name="object.id"/>
  75. </xsl:attribute>
  76. </xsl:if>
  77. <xsl:call-template name="setindex.titlepage"/>
  78. <xsl:apply-templates/>
  79. <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
  80. <xsl:call-template name="generate-index">
  81. <xsl:with-param name="scope" select="/"/>
  82. </xsl:call-template>
  83. </xsl:if>
  84. <xsl:if test="not(parent::article)">
  85. <xsl:call-template name="process.footnotes"/>
  86. </xsl:if>
  87. </div>
  88. </xsl:if>
  89. </xsl:template>
  90. <xsl:template match="index/indexinfo"/>
  91. <xsl:template match="index/info"/>
  92. <xsl:template match="index/title"/>
  93. <xsl:template match="index/subtitle"/>
  94. <xsl:template match="index/titleabbrev"/>
  95. <!-- ==================================================================== -->
  96. <xsl:template match="indexdiv">
  97. <xsl:call-template name="id.warning"/>
  98. <div>
  99. <xsl:apply-templates select="." mode="class.attribute"/>
  100. <xsl:if test="$generate.id.attributes != 0">
  101. <xsl:attribute name="id">
  102. <xsl:call-template name="object.id"/>
  103. </xsl:attribute>
  104. </xsl:if>
  105. <xsl:call-template name="anchor"/>
  106. <xsl:apply-templates select="*[not(self::indexentry)]"/>
  107. <dl>
  108. <xsl:apply-templates select="indexentry"/>
  109. </dl>
  110. </div>
  111. </xsl:template>
  112. <xsl:template match="indexdiv/title">
  113. <h3>
  114. <xsl:apply-templates select="." mode="class.attribute"/>
  115. <xsl:apply-templates/>
  116. </h3>
  117. </xsl:template>
  118. <!-- ==================================================================== -->
  119. <xsl:template match="indexterm">
  120. <!-- this one must have a name, even if it doesn't have an ID -->
  121. <xsl:variable name="id">
  122. <xsl:call-template name="object.id"/>
  123. </xsl:variable>
  124. <a id="{$id}" class="indexterm"/>
  125. </xsl:template>
  126. <xsl:template match="primary|secondary|tertiary|see|seealso">
  127. </xsl:template>
  128. <!-- ==================================================================== -->
  129. <xsl:template match="indexentry">
  130. <xsl:apply-templates select="primaryie"/>
  131. </xsl:template>
  132. <xsl:template match="primaryie">
  133. <dt>
  134. <xsl:apply-templates/>
  135. </dt>
  136. <xsl:choose>
  137. <xsl:when test="following-sibling::secondaryie">
  138. <dd>
  139. <dl>
  140. <xsl:apply-templates select="following-sibling::secondaryie"/>
  141. </dl>
  142. </dd>
  143. </xsl:when>
  144. <xsl:when test="following-sibling::seeie |following-sibling::seealsoie">
  145. <dd>
  146. <dl>
  147. <xsl:apply-templates select="following-sibling::seeie |following-sibling::seealsoie"/>
  148. </dl>
  149. </dd>
  150. </xsl:when>
  151. </xsl:choose>
  152. </xsl:template>
  153. <xsl:template match="secondaryie">
  154. <dt>
  155. <xsl:apply-templates/>
  156. </dt>
  157. <xsl:choose>
  158. <xsl:when test="following-sibling::tertiaryie">
  159. <dd>
  160. <dl>
  161. <xsl:apply-templates select="following-sibling::tertiaryie"/>
  162. </dl>
  163. </dd>
  164. </xsl:when>
  165. <xsl:when test="following-sibling::seeie |following-sibling::seealsoie">
  166. <dd>
  167. <dl>
  168. <xsl:apply-templates select="following-sibling::seeie |following-sibling::seealsoie"/>
  169. </dl>
  170. </dd>
  171. </xsl:when>
  172. </xsl:choose>
  173. </xsl:template>
  174. <xsl:template match="tertiaryie">
  175. <dt>
  176. <xsl:apply-templates/>
  177. </dt>
  178. <xsl:if test="following-sibling::seeie |following-sibling::seealsoie">
  179. <dd>
  180. <dl>
  181. <xsl:apply-templates select="following-sibling::seeie |following-sibling::seealsoie"/>
  182. </dl>
  183. </dd>
  184. </xsl:if>
  185. </xsl:template>
  186. <xsl:template match="seeie|seealsoie">
  187. <dt>
  188. <xsl:apply-templates/>
  189. </dt>
  190. </xsl:template>
  191. </xsl:stylesheet>