autotoc.xsl 24 KB

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