index.xsl 9.5 KB

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