autotoc.xsl 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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: autotoc.xsl 9692 2012-12-16 02:31:34Z dcramer $
  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. <xsl:variable name="toc.listitem.type">
  13. <xsl:choose>
  14. <xsl:when test="$toc.list.type = 'dl'">dt</xsl:when>
  15. <xsl:otherwise>li</xsl:otherwise>
  16. </xsl:choose>
  17. </xsl:variable>
  18. <!-- this is just hack because dl and ul aren't completely isomorphic -->
  19. <xsl:variable name="toc.dd.type">
  20. <xsl:choose>
  21. <xsl:when test="$toc.list.type = 'dl'">dd</xsl:when>
  22. <xsl:otherwise/>
  23. </xsl:choose>
  24. </xsl:variable>
  25. <xsl:template name="make.toc">
  26. <xsl:param name="toc-context" select="."/>
  27. <xsl:param name="toc.title.p" select="true()"/>
  28. <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
  29. <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
  30. <xsl:variable name="toc.title">
  31. <xsl:if test="$toc.title.p">
  32. <xsl:choose>
  33. <xsl:when test="$make.clean.html != 0">
  34. <div class="toc-title">
  35. <xsl:call-template name="gentext">
  36. <xsl:with-param name="key">TableofContents</xsl:with-param>
  37. </xsl:call-template>
  38. </div>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <p>
  42. <strong xmlns:xslo="http://www.w3.org/1999/XSL/Transform">
  43. <xsl:call-template name="gentext">
  44. <xsl:with-param name="key">TableofContents</xsl:with-param>
  45. </xsl:call-template>
  46. </strong>
  47. </p>
  48. </xsl:otherwise>
  49. </xsl:choose>
  50. </xsl:if>
  51. </xsl:variable>
  52. <xsl:choose>
  53. <xsl:when test="$manual.toc != ''">
  54. <xsl:variable name="id">
  55. <xsl:call-template name="object.id"/>
  56. </xsl:variable>
  57. <xsl:variable name="toc" select="document($manual.toc, .)"/>
  58. <xsl:variable name="tocentry" select="$toc//tocentry[@linkend=$id]"/>
  59. <xsl:if test="$tocentry and $tocentry/*">
  60. <div class="toc">
  61. <xsl:copy-of select="$toc.title"/>
  62. <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
  63. <xsl:call-template name="toc.list.attributes">
  64. <xsl:with-param name="toc-context" select="$toc-context"/>
  65. <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
  66. <xsl:with-param name="nodes" select="$nodes"/>
  67. </xsl:call-template>
  68. <xsl:call-template name="manual-toc">
  69. <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
  70. </xsl:call-template>
  71. </xsl:element>
  72. </div>
  73. </xsl:if>
  74. </xsl:when>
  75. <xsl:otherwise>
  76. <xsl:choose>
  77. <xsl:when test="$qanda.in.toc != 0">
  78. <xsl:if test="$nodes.plus">
  79. <div class="toc">
  80. <xsl:copy-of select="$toc.title"/>
  81. <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
  82. <xsl:call-template name="toc.list.attributes">
  83. <xsl:with-param name="toc-context" select="$toc-context"/>
  84. <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
  85. <xsl:with-param name="nodes" select="$nodes"/>
  86. </xsl:call-template>
  87. <xsl:apply-templates select="$nodes.plus" mode="toc">
  88. <xsl:with-param name="toc-context" select="$toc-context"/>
  89. </xsl:apply-templates>
  90. </xsl:element>
  91. </div>
  92. </xsl:if>
  93. </xsl:when>
  94. <xsl:otherwise>
  95. <xsl:if test="$nodes">
  96. <div class="toc">
  97. <xsl:copy-of select="$toc.title"/>
  98. <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
  99. <xsl:call-template name="toc.list.attributes">
  100. <xsl:with-param name="toc-context" select="$toc-context"/>
  101. <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
  102. <xsl:with-param name="nodes" select="$nodes"/>
  103. </xsl:call-template>
  104. <xsl:apply-templates select="$nodes" mode="toc">
  105. <xsl:with-param name="toc-context" select="$toc-context"/>
  106. </xsl:apply-templates>
  107. </xsl:element>
  108. </div>
  109. </xsl:if>
  110. </xsl:otherwise>
  111. </xsl:choose>
  112. </xsl:otherwise>
  113. </xsl:choose>
  114. </xsl:template>
  115. <xsl:template name="toc.list.attributes">
  116. <xsl:param name="toc-context" select="."/>
  117. <xsl:param name="toc.title.p" select="true()"/>
  118. <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
  119. <xsl:attribute name="class">toc</xsl:attribute>
  120. </xsl:template>
  121. <xsl:template name="make.lots">
  122. <xsl:param name="toc.params" select="''"/>
  123. <xsl:param name="toc"/>
  124. <xsl:if test="contains($toc.params, 'toc')">
  125. <xsl:copy-of select="$toc"/>
  126. </xsl:if>
  127. <xsl:if test="contains($toc.params, 'figure')">
  128. <xsl:call-template name="list.of.titles">
  129. <xsl:with-param name="titles" select="'figure'"/>
  130. <xsl:with-param name="nodes" select=".//figure"/>
  131. </xsl:call-template>
  132. </xsl:if>
  133. <xsl:if test="contains($toc.params, 'table')">
  134. <xsl:call-template name="list.of.titles">
  135. <xsl:with-param name="titles" select="'table'"/>
  136. <xsl:with-param name="nodes" select=".//table[not(@tocentry = 0)]"/>
  137. </xsl:call-template>
  138. </xsl:if>
  139. <xsl:if test="contains($toc.params, 'example')">
  140. <xsl:call-template name="list.of.titles">
  141. <xsl:with-param name="titles" select="'example'"/>
  142. <xsl:with-param name="nodes" select=".//example"/>
  143. </xsl:call-template>
  144. </xsl:if>
  145. <xsl:if test="contains($toc.params, 'equation')">
  146. <xsl:call-template name="list.of.titles">
  147. <xsl:with-param name="titles" select="'equation'"/>
  148. <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
  149. </xsl:call-template>
  150. </xsl:if>
  151. <xsl:if test="contains($toc.params, 'procedure')">
  152. <xsl:call-template name="list.of.titles">
  153. <xsl:with-param name="titles" select="'procedure'"/>
  154. <xsl:with-param name="nodes" select=".//procedure[title]"/>
  155. </xsl:call-template>
  156. </xsl:if>
  157. </xsl:template>
  158. <!-- ====================================================================== -->
  159. <xsl:template name="set.toc">
  160. <xsl:param name="toc-context" select="."/>
  161. <xsl:param name="toc.title.p" select="true()"/>
  162. <xsl:call-template name="make.toc">
  163. <xsl:with-param name="toc-context" select="$toc-context"/>
  164. <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
  165. <xsl:with-param name="nodes" select="book|setindex|set"/>
  166. </xsl:call-template>
  167. </xsl:template>
  168. <xsl:template name="division.toc">
  169. <xsl:param name="toc-context" select="."/>
  170. <xsl:param name="toc.title.p" select="true()"/>
  171. <xsl:call-template name="make.toc">
  172. <xsl:with-param name="toc-context" select="$toc-context"/>
  173. <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
  174. <xsl:with-param name="nodes" select="part|reference |preface|chapter|appendix |article |topic |bibliography|glossary|index |refentry |bridgehead[$bridgehead.in.toc != 0]"/>
  175. </xsl:call-template>
  176. </xsl:template>
  177. <xsl:template name="component.toc">
  178. <xsl:param name="toc-context" select="."/>
  179. <xsl:param name="toc.title.p" select="true()"/>
  180. <xsl:call-template name="make.toc">
  181. <xsl:with-param name="toc-context" select="$toc-context"/>
  182. <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
  183. <xsl:with-param name="nodes" select="section|sect1 |simplesect[$simplesect.in.toc != 0] |topic |refentry |article|bibliography|glossary |appendix|index |bridgehead[not(@renderas) and $bridgehead.in.toc != 0] |.//bridgehead[@renderas='sect1' and $bridgehead.in.toc != 0]"/>
  184. </xsl:call-template>
  185. </xsl:template>
  186. <xsl:template name="component.toc.separator">
  187. <!-- Customize to output something between
  188. component.toc and first output -->
  189. </xsl:template>
  190. <xsl:template name="section.toc">
  191. <xsl:param name="toc-context" select="."/>
  192. <xsl:param name="toc.title.p" select="true()"/>
  193. <xsl:call-template name="make.toc">
  194. <xsl:with-param name="toc-context" select="$toc-context"/>
  195. <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
  196. <xsl:with-param name="nodes" select="section|sect1|sect2|sect3|sect4|sect5|refentry |bridgehead[$bridgehead.in.toc != 0]"/>
  197. </xsl:call-template>
  198. </xsl:template>
  199. <xsl:template name="section.toc.separator">
  200. <!-- Customize to output something between
  201. section.toc and first output -->
  202. </xsl:template>
  203. <!-- ==================================================================== -->
  204. <xsl:template name="subtoc">
  205. <xsl:param name="toc-context" select="."/>
  206. <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
  207. <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
  208. <xsl:variable name="subtoc">
  209. <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
  210. <xsl:choose>
  211. <xsl:when test="$qanda.in.toc != 0">
  212. <xsl:apply-templates mode="toc" select="$nodes.plus">
  213. <xsl:with-param name="toc-context" select="$toc-context"/>
  214. </xsl:apply-templates>
  215. </xsl:when>
  216. <xsl:otherwise>
  217. <xsl:apply-templates mode="toc" select="$nodes">
  218. <xsl:with-param name="toc-context" select="$toc-context"/>
  219. </xsl:apply-templates>
  220. </xsl:otherwise>
  221. </xsl:choose>
  222. </xsl:element>
  223. </xsl:variable>
  224. <xsl:variable name="depth">
  225. <xsl:choose>
  226. <xsl:when test="local-name(.) = 'section'">
  227. <xsl:value-of select="count(ancestor::section) + 1"/>
  228. </xsl:when>
  229. <xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
  230. <xsl:when test="local-name(.) = 'sect2'">2</xsl:when>
  231. <xsl:when test="local-name(.) = 'sect3'">3</xsl:when>
  232. <xsl:when test="local-name(.) = 'sect4'">4</xsl:when>
  233. <xsl:when test="local-name(.) = 'sect5'">5</xsl:when>
  234. <xsl:when test="local-name(.) = 'refsect1'">1</xsl:when>
  235. <xsl:when test="local-name(.) = 'refsect2'">2</xsl:when>
  236. <xsl:when test="local-name(.) = 'refsect3'">3</xsl:when>
  237. <xsl:when test="local-name(.) = 'topic'">1</xsl:when>
  238. <xsl:when test="local-name(.) = 'simplesect'">
  239. <!-- sigh... -->
  240. <xsl:choose>
  241. <xsl:when test="local-name(..) = 'section'">
  242. <xsl:value-of select="count(ancestor::section)"/>
  243. </xsl:when>
  244. <xsl:when test="local-name(..) = 'sect1'">2</xsl:when>
  245. <xsl:when test="local-name(..) = 'sect2'">3</xsl:when>
  246. <xsl:when test="local-name(..) = 'sect3'">4</xsl:when>
  247. <xsl:when test="local-name(..) = 'sect4'">5</xsl:when>
  248. <xsl:when test="local-name(..) = 'sect5'">6</xsl:when>
  249. <xsl:when test="local-name(..) = 'topic'">2</xsl:when>
  250. <xsl:when test="local-name(..) = 'refsect1'">2</xsl:when>
  251. <xsl:when test="local-name(..) = 'refsect2'">3</xsl:when>
  252. <xsl:when test="local-name(..) = 'refsect3'">4</xsl:when>
  253. <xsl:otherwise>1</xsl:otherwise>
  254. </xsl:choose>
  255. </xsl:when>
  256. <xsl:otherwise>0</xsl:otherwise>
  257. </xsl:choose>
  258. </xsl:variable>
  259. <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
  260. <xsl:variable name="subtoc.list">
  261. <xsl:choose>
  262. <xsl:when test="$toc.dd.type = ''">
  263. <xsl:copy-of select="$subtoc"/>
  264. </xsl:when>
  265. <xsl:otherwise>
  266. <xsl:element name="{$toc.dd.type}" namespace="http://www.w3.org/1999/xhtml">
  267. <xsl:copy-of select="$subtoc"/>
  268. </xsl:element>
  269. </xsl:otherwise>
  270. </xsl:choose>
  271. </xsl:variable>
  272. <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
  273. <xsl:call-template name="toc.line">
  274. <xsl:with-param name="toc-context" select="$toc-context"/>
  275. </xsl:call-template>
  276. <xsl:if test="$toc.listitem.type = 'li' and ( (self::set or self::book or self::part) or $toc.section.depth &gt; $depth) and ( ($qanda.in.toc = 0 and count($nodes)&gt;0) or ($qanda.in.toc != 0 and count($nodes.plus)&gt;0) ) and $toc.max.depth &gt; $depth.from.context">
  277. <xsl:copy-of select="$subtoc.list"/>
  278. </xsl:if>
  279. </xsl:element>
  280. <xsl:if test="$toc.listitem.type != 'li' and ( (self::set or self::book or self::part) or $toc.section.depth &gt; $depth) and ( ($qanda.in.toc = 0 and count($nodes)&gt;0) or ($qanda.in.toc != 0 and count($nodes.plus)&gt;0) ) and $toc.max.depth &gt; $depth.from.context">
  281. <xsl:copy-of select="$subtoc.list"/>
  282. </xsl:if>
  283. </xsl:template>
  284. <xsl:template name="toc.line">
  285. <xsl:param name="toc-context" select="."/>
  286. <xsl:param name="depth" select="1"/>
  287. <xsl:param name="depth.from.context" select="8"/>
  288. <span>
  289. <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
  290. <!-- * if $autotoc.label.in.hyperlink is zero, then output the label -->
  291. <!-- * before the hyperlinked title (as the DSSSL stylesheet does) -->
  292. <xsl:if test="$autotoc.label.in.hyperlink = 0">
  293. <xsl:variable name="label">
  294. <xsl:apply-templates select="." mode="label.markup"/>
  295. </xsl:variable>
  296. <xsl:copy-of select="$label"/>
  297. <xsl:if test="$label != ''">
  298. <xsl:value-of select="$autotoc.label.separator"/>
  299. </xsl:if>
  300. </xsl:if>
  301. <a>
  302. <xsl:attribute name="href">
  303. <xsl:call-template name="href.target">
  304. <xsl:with-param name="context" select="$toc-context"/>
  305. <xsl:with-param name="toc-context" select="$toc-context"/>
  306. </xsl:call-template>
  307. </xsl:attribute>
  308. <!-- * if $autotoc.label.in.hyperlink is non-zero, then output the label -->
  309. <!-- * as part of the hyperlinked title -->
  310. <xsl:if test="not($autotoc.label.in.hyperlink = 0)">
  311. <xsl:variable name="label">
  312. <xsl:apply-templates select="." mode="label.markup"/>
  313. </xsl:variable>
  314. <xsl:copy-of select="$label"/>
  315. <xsl:if test="$label != ''">
  316. <xsl:value-of select="$autotoc.label.separator"/>
  317. </xsl:if>
  318. </xsl:if>
  319. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  320. </a>
  321. </span>
  322. </xsl:template>
  323. <xsl:template match="book" mode="toc">
  324. <xsl:param name="toc-context" select="."/>
  325. <xsl:call-template name="subtoc">
  326. <xsl:with-param name="toc-context" select="$toc-context"/>
  327. <xsl:with-param name="nodes" select="part|reference |preface|chapter|appendix |article |topic |bibliography|glossary|index |refentry |bridgehead[$bridgehead.in.toc != 0]"/>
  328. </xsl:call-template>
  329. </xsl:template>
  330. <xsl:template match="setindex" mode="toc">
  331. <xsl:param name="toc-context" select="."/>
  332. <!-- If the setindex tag is not empty, it should be it in the TOC -->
  333. <xsl:if test="* or $generate.index != 0">
  334. <xsl:call-template name="subtoc">
  335. <xsl:with-param name="toc-context" select="$toc-context"/>
  336. </xsl:call-template>
  337. </xsl:if>
  338. </xsl:template>
  339. <xsl:template match="part|reference" mode="toc">
  340. <xsl:param name="toc-context" select="."/>
  341. <xsl:call-template name="subtoc">
  342. <xsl:with-param name="toc-context" select="$toc-context"/>
  343. <xsl:with-param name="nodes" select="appendix|chapter|article|topic |index|glossary|bibliography |preface|reference|refentry |bridgehead[$bridgehead.in.toc != 0]"/>
  344. </xsl:call-template>
  345. </xsl:template>
  346. <xsl:template match="preface|chapter|appendix|article|topic" mode="toc">
  347. <xsl:param name="toc-context" select="."/>
  348. <xsl:call-template name="subtoc">
  349. <xsl:with-param name="toc-context" select="$toc-context"/>
  350. <xsl:with-param name="nodes" select="section|sect1 |simplesect[$simplesect.in.toc != 0] |topic |refentry |glossary|bibliography|index |bridgehead[$bridgehead.in.toc != 0]"/>
  351. </xsl:call-template>
  352. </xsl:template>
  353. <xsl:template match="sect1" mode="toc">
  354. <xsl:param name="toc-context" select="."/>
  355. <xsl:call-template name="subtoc">
  356. <xsl:with-param name="toc-context" select="$toc-context"/>
  357. <xsl:with-param name="nodes" select="sect2 |bridgehead[$bridgehead.in.toc != 0]"/>
  358. </xsl:call-template>
  359. </xsl:template>
  360. <xsl:template match="sect2" mode="toc">
  361. <xsl:param name="toc-context" select="."/>
  362. <xsl:call-template name="subtoc">
  363. <xsl:with-param name="toc-context" select="$toc-context"/>
  364. <xsl:with-param name="nodes" select="sect3 |bridgehead[$bridgehead.in.toc != 0]"/>
  365. </xsl:call-template>
  366. </xsl:template>
  367. <xsl:template match="sect3" mode="toc">
  368. <xsl:param name="toc-context" select="."/>
  369. <xsl:call-template name="subtoc">
  370. <xsl:with-param name="toc-context" select="$toc-context"/>
  371. <xsl:with-param name="nodes" select="sect4 |bridgehead[$bridgehead.in.toc != 0]"/>
  372. </xsl:call-template>
  373. </xsl:template>
  374. <xsl:template match="sect4" mode="toc">
  375. <xsl:param name="toc-context" select="."/>
  376. <xsl:call-template name="subtoc">
  377. <xsl:with-param name="toc-context" select="$toc-context"/>
  378. <xsl:with-param name="nodes" select="sect5 |bridgehead[$bridgehead.in.toc != 0]"/>
  379. </xsl:call-template>
  380. </xsl:template>
  381. <xsl:template match="sect5" mode="toc">
  382. <xsl:param name="toc-context" select="."/>
  383. <xsl:call-template name="subtoc">
  384. <xsl:with-param name="toc-context" select="$toc-context"/>
  385. </xsl:call-template>
  386. </xsl:template>
  387. <xsl:template match="simplesect" mode="toc">
  388. <xsl:param name="toc-context" select="."/>
  389. <xsl:call-template name="subtoc">
  390. <xsl:with-param name="toc-context" select="$toc-context"/>
  391. </xsl:call-template>
  392. </xsl:template>
  393. <xsl:template match="section" mode="toc">
  394. <xsl:param name="toc-context" select="."/>
  395. <xsl:call-template name="subtoc">
  396. <xsl:with-param name="toc-context" select="$toc-context"/>
  397. <xsl:with-param name="nodes" select="section|refentry |simplesect[$simplesect.in.toc != 0] |bridgehead[$bridgehead.in.toc != 0]"/>
  398. </xsl:call-template>
  399. </xsl:template>
  400. <xsl:template match="topic" mode="toc">
  401. <xsl:param name="toc-context" select="."/>
  402. <xsl:call-template name="subtoc">
  403. <xsl:with-param name="toc-context" select="$toc-context"/>
  404. <xsl:with-param name="nodes" select="section|refentry |simplesect[$simplesect.in.toc != 0] |bridgehead[$bridgehead.in.toc != 0]"/>
  405. </xsl:call-template>
  406. </xsl:template>
  407. <xsl:template match="bridgehead" mode="toc">
  408. <xsl:param name="toc-context" select="."/>
  409. <xsl:if test="$bridgehead.in.toc != 0">
  410. <xsl:call-template name="subtoc">
  411. <xsl:with-param name="toc-context" select="$toc-context"/>
  412. </xsl:call-template>
  413. </xsl:if>
  414. </xsl:template>
  415. <xsl:template match="bibliography|glossary" mode="toc">
  416. <xsl:param name="toc-context" select="."/>
  417. <xsl:call-template name="subtoc">
  418. <xsl:with-param name="toc-context" select="$toc-context"/>
  419. </xsl:call-template>
  420. </xsl:template>
  421. <xsl:template match="index" mode="toc">
  422. <xsl:param name="toc-context" select="."/>
  423. <!-- If the index tag is not empty, it should be it in the TOC -->
  424. <xsl:if test="* or $generate.index != 0">
  425. <xsl:call-template name="subtoc">
  426. <xsl:with-param name="toc-context" select="$toc-context"/>
  427. </xsl:call-template>
  428. </xsl:if>
  429. </xsl:template>
  430. <xsl:template match="refentry" mode="toc">
  431. <xsl:param name="toc-context" select="."/>
  432. <xsl:variable name="refmeta" select=".//refmeta"/>
  433. <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
  434. <xsl:variable name="refnamediv" select=".//refnamediv"/>
  435. <xsl:variable name="refname" select="$refnamediv//refname"/>
  436. <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
  437. <xsl:variable name="title">
  438. <xsl:choose>
  439. <xsl:when test="$refentrytitle">
  440. <xsl:apply-templates select="$refentrytitle[1]" mode="titleabbrev.markup"/>
  441. </xsl:when>
  442. <xsl:when test="$refdesc">
  443. <xsl:apply-templates select="$refdesc" mode="titleabbrev.markup"/>
  444. </xsl:when>
  445. <xsl:when test="$refname">
  446. <xsl:apply-templates select="$refname[1]" mode="titleabbrev.markup"/>
  447. </xsl:when>
  448. </xsl:choose>
  449. </xsl:variable>
  450. <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
  451. <span class="refentrytitle">
  452. <a>
  453. <xsl:attribute name="href">
  454. <xsl:call-template name="href.target">
  455. <xsl:with-param name="toc-context" select="$toc-context"/>
  456. </xsl:call-template>
  457. </xsl:attribute>
  458. <xsl:copy-of select="$title"/>
  459. </a>
  460. </span>
  461. <span class="refpurpose">
  462. <xsl:if test="$annotate.toc != 0">
  463. <!-- * DocBook 5 says inlinemediaobject (among other things) -->
  464. <!-- * is allowed in refpurpose; so we need to run -->
  465. <!-- * apply-templates on refpurpose here, instead of value-of -->
  466. <xsl:apply-templates select="refnamediv/refpurpose" mode="no.anchor.mode"/>
  467. </xsl:if>
  468. </span>
  469. </xsl:element>
  470. </xsl:template>
  471. <xsl:template match="title" mode="toc">
  472. <xsl:param name="toc-context" select="."/>
  473. <a>
  474. <xsl:attribute name="href">
  475. <xsl:call-template name="href.target">
  476. <xsl:with-param name="object" select=".."/>
  477. <xsl:with-param name="toc-context" select="$toc-context"/>
  478. </xsl:call-template>
  479. </xsl:attribute>
  480. <xsl:apply-templates/>
  481. </a>
  482. </xsl:template>
  483. <xsl:template name="manual-toc">
  484. <xsl:param name="toc-context" select="."/>
  485. <xsl:param name="tocentry"/>
  486. <xsl:param name="toc.title.p" select="true()"/>
  487. <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
  488. <!-- be careful, we don't want to change the current document to the other tree! -->
  489. <xsl:if test="$tocentry">
  490. <xsl:variable name="node" select="key('id', $tocentry/@linkend)"/>
  491. <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
  492. <xsl:variable name="label">
  493. <xsl:apply-templates select="$node" mode="label.markup"/>
  494. </xsl:variable>
  495. <xsl:copy-of select="$label"/>
  496. <xsl:if test="$label != ''">
  497. <xsl:value-of select="$autotoc.label.separator"/>
  498. </xsl:if>
  499. <a>
  500. <xsl:attribute name="href">
  501. <xsl:call-template name="href.target">
  502. <xsl:with-param name="object" select="$node"/>
  503. <xsl:with-param name="toc-context" select="$toc-context"/>
  504. </xsl:call-template>
  505. </xsl:attribute>
  506. <xsl:apply-templates select="$node" mode="titleabbrev.markup"/>
  507. </a>
  508. </xsl:element>
  509. <xsl:if test="$tocentry/*">
  510. <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
  511. <xsl:call-template name="toc.list.attributes">
  512. <xsl:with-param name="toc-context" select="$toc-context"/>
  513. <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
  514. <xsl:with-param name="nodes" select="$nodes"/>
  515. </xsl:call-template>
  516. <xsl:call-template name="manual-toc">
  517. <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
  518. </xsl:call-template>
  519. </xsl:element>
  520. </xsl:if>
  521. <xsl:if test="$tocentry/following-sibling::*">
  522. <xsl:call-template name="manual-toc">
  523. <xsl:with-param name="tocentry" select="$tocentry/following-sibling::*[1]"/>
  524. </xsl:call-template>
  525. </xsl:if>
  526. </xsl:if>
  527. </xsl:template>
  528. <!-- ==================================================================== -->
  529. <xsl:template name="list.of.titles">
  530. <xsl:param name="toc-context" select="."/>
  531. <xsl:param name="titles" select="'table'"/>
  532. <xsl:param name="nodes" select=".//table"/>
  533. <xsl:if test="$nodes">
  534. <div class="list-of-{$titles}s">
  535. <xsl:choose>
  536. <xsl:when test="$make.clean.html != 0">
  537. <div class="toc-title">
  538. <xsl:call-template name="gentext">
  539. <xsl:with-param name="key">
  540. <xsl:choose>
  541. <xsl:when test="$titles='table'">ListofTables</xsl:when>
  542. <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
  543. <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
  544. <xsl:when test="$titles='example'">ListofExamples</xsl:when>
  545. <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
  546. <xsl:otherwise>ListofUnknown</xsl:otherwise>
  547. </xsl:choose>
  548. </xsl:with-param>
  549. </xsl:call-template>
  550. </div>
  551. </xsl:when>
  552. <xsl:otherwise>
  553. <p>
  554. <strong xmlns:xslo="http://www.w3.org/1999/XSL/Transform">
  555. <xsl:call-template name="gentext">
  556. <xsl:with-param name="key">
  557. <xsl:choose>
  558. <xsl:when test="$titles='table'">ListofTables</xsl:when>
  559. <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
  560. <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
  561. <xsl:when test="$titles='example'">ListofExamples</xsl:when>
  562. <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
  563. <xsl:otherwise>ListofUnknown</xsl:otherwise>
  564. </xsl:choose>
  565. </xsl:with-param>
  566. </xsl:call-template>
  567. </strong>
  568. </p>
  569. </xsl:otherwise>
  570. </xsl:choose>
  571. <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
  572. <xsl:apply-templates select="$nodes" mode="toc">
  573. <xsl:with-param name="toc-context" select="$toc-context"/>
  574. </xsl:apply-templates>
  575. </xsl:element>
  576. </div>
  577. </xsl:if>
  578. </xsl:template>
  579. <xsl:template match="figure|table|example|equation|procedure" mode="toc">
  580. <xsl:param name="toc-context" select="."/>
  581. <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
  582. <xsl:variable name="label">
  583. <xsl:apply-templates select="." mode="label.markup"/>
  584. </xsl:variable>
  585. <xsl:copy-of select="$label"/>
  586. <xsl:if test="$label != ''">
  587. <xsl:value-of select="$autotoc.label.separator"/>
  588. </xsl:if>
  589. <a>
  590. <xsl:attribute name="href">
  591. <xsl:call-template name="href.target">
  592. <xsl:with-param name="toc-context" select="$toc-context"/>
  593. </xsl:call-template>
  594. </xsl:attribute>
  595. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  596. </a>
  597. </xsl:element>
  598. </xsl:template>
  599. <!-- Used only if qanda.in.toc parameter is non-zero -->
  600. <xsl:template match="qandaset" mode="toc">
  601. <xsl:param name="toc-context" select="."/>
  602. <xsl:call-template name="subtoc">
  603. <xsl:with-param name="toc-context" select="$toc-context"/>
  604. <xsl:with-param name="nodes" select="qandadiv | qandaentry"/>
  605. </xsl:call-template>
  606. </xsl:template>
  607. <xsl:template match="qandadiv|qandaentry" mode="toc">
  608. <xsl:apply-templates select="." mode="qandatoc.mode"/>
  609. </xsl:template>
  610. </xsl:stylesheet>