footnote.xsl 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?xml version="1.0" encoding="US-ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML stylesheets. Do not edit this file.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl" version="1.0">
  5. <!-- ********************************************************************
  6. $Id$
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  10. and other information.
  11. ******************************************************************** -->
  12. <xsl:template match="footnote">
  13. <xsl:variable name="name">
  14. <xsl:call-template name="object.id"/>
  15. </xsl:variable>
  16. <xsl:variable name="href">
  17. <xsl:text>#ftn.</xsl:text>
  18. <xsl:call-template name="object.id"/>
  19. </xsl:variable>
  20. <xsl:choose>
  21. <xsl:when test="ancestor::tgroup">
  22. <sup>
  23. <xsl:text>[</xsl:text>
  24. <a id="{$name}" href="{$href}">
  25. <xsl:apply-templates select="." mode="class.attribute"/>
  26. <xsl:apply-templates select="." mode="footnote.number"/>
  27. </a>
  28. <xsl:text>]</xsl:text>
  29. </sup>
  30. </xsl:when>
  31. <xsl:otherwise>
  32. <sup>
  33. <xsl:text>[</xsl:text>
  34. <a id="{$name}" href="{$href}">
  35. <xsl:apply-templates select="." mode="class.attribute"/>
  36. <xsl:apply-templates select="." mode="footnote.number"/>
  37. </a>
  38. <xsl:text>]</xsl:text>
  39. </sup>
  40. </xsl:otherwise>
  41. </xsl:choose>
  42. </xsl:template>
  43. <xsl:template match="footnoteref">
  44. <xsl:variable name="targets" select="key('id',@linkend)"/>
  45. <xsl:variable name="footnote" select="$targets[1]"/>
  46. <xsl:variable name="href">
  47. <xsl:text>#ftn.</xsl:text>
  48. <xsl:call-template name="object.id">
  49. <xsl:with-param name="object" select="$footnote"/>
  50. </xsl:call-template>
  51. </xsl:variable>
  52. <sup>
  53. <xsl:text>[</xsl:text>
  54. <a href="{$href}">
  55. <xsl:apply-templates select="." mode="class.attribute"/>
  56. <xsl:apply-templates select="$footnote" mode="footnote.number"/>
  57. </a>
  58. <xsl:text>]</xsl:text>
  59. </sup>
  60. </xsl:template>
  61. <xsl:template match="footnote" mode="footnote.number">
  62. <xsl:choose>
  63. <xsl:when test="string-length(@label) != 0">
  64. <xsl:value-of select="@label"/>
  65. </xsl:when>
  66. <xsl:when test="ancestor::tgroup">
  67. <xsl:variable name="tfnum">
  68. <xsl:number level="any" from="table|informaltable" format="1"/>
  69. </xsl:variable>
  70. <xsl:choose>
  71. <xsl:when test="string-length($table.footnote.number.symbols) &gt;= $tfnum">
  72. <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
  73. </xsl:when>
  74. <xsl:otherwise>
  75. <xsl:number level="any" from="tgroup" format="{$table.footnote.number.format}"/>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </xsl:when>
  79. <xsl:otherwise>
  80. <xsl:variable name="pfoot" select="preceding::footnote[not(@label)]"/>
  81. <xsl:variable name="ptfoot" select="preceding::tgroup//footnote"/>
  82. <xsl:variable name="fnum" select="count($pfoot) - count($ptfoot) + 1"/>
  83. <xsl:choose>
  84. <xsl:when test="string-length($footnote.number.symbols) &gt;= $fnum">
  85. <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
  86. </xsl:when>
  87. <xsl:otherwise>
  88. <xsl:number value="$fnum" format="{$footnote.number.format}"/>
  89. </xsl:otherwise>
  90. </xsl:choose>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. </xsl:template>
  94. <!-- ==================================================================== -->
  95. <xsl:template match="footnote/para[1]|footnote/simpara[1]" priority="2">
  96. <!-- this only works if the first thing in a footnote is a para, -->
  97. <!-- which is ok, because it usually is. -->
  98. <xsl:variable name="name">
  99. <xsl:text>ftn.</xsl:text>
  100. <xsl:call-template name="object.id">
  101. <xsl:with-param name="object" select="ancestor::footnote"/>
  102. </xsl:call-template>
  103. </xsl:variable>
  104. <xsl:variable name="href">
  105. <xsl:text>#</xsl:text>
  106. <xsl:call-template name="object.id">
  107. <xsl:with-param name="object" select="ancestor::footnote"/>
  108. </xsl:call-template>
  109. </xsl:variable>
  110. <p>
  111. <xsl:if test="@role and $para.propagates.style != 0">
  112. <xsl:apply-templates select="." mode="class.attribute">
  113. <xsl:with-param name="class" select="@role"/>
  114. </xsl:apply-templates>
  115. </xsl:if>
  116. <sup>
  117. <xsl:text>[</xsl:text>
  118. <a id="{$name}" href="{$href}">
  119. <xsl:apply-templates select="." mode="class.attribute"/>
  120. <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
  121. </a>
  122. <xsl:text>] </xsl:text>
  123. </sup>
  124. <xsl:apply-templates/>
  125. </p>
  126. </xsl:template>
  127. <!-- ==================================================================== -->
  128. <xsl:template match="*" mode="footnote.body.number">
  129. <xsl:variable name="name">
  130. <xsl:text>ftn.</xsl:text>
  131. <xsl:call-template name="object.id">
  132. <xsl:with-param name="object" select="ancestor::footnote"/>
  133. </xsl:call-template>
  134. </xsl:variable>
  135. <xsl:variable name="href">
  136. <xsl:text>#</xsl:text>
  137. <xsl:call-template name="object.id">
  138. <xsl:with-param name="object" select="ancestor::footnote"/>
  139. </xsl:call-template>
  140. </xsl:variable>
  141. <xsl:variable name="footnote.mark">
  142. <sup>
  143. <xsl:text>[</xsl:text>
  144. <a id="{$name}" href="{$href}">
  145. <xsl:apply-templates select="." mode="class.attribute"/>
  146. <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
  147. </a>
  148. <xsl:text>] </xsl:text>
  149. </sup>
  150. </xsl:variable>
  151. <xsl:variable name="html">
  152. <xsl:apply-templates select="."/>
  153. </xsl:variable>
  154. <xsl:choose>
  155. <xsl:when test="function-available('exsl:node-set')">
  156. <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
  157. <xsl:choose>
  158. <xsl:when test="$html-nodes//p">
  159. <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
  160. <xsl:with-param name="mark" select="$footnote.mark"/>
  161. </xsl:apply-templates>
  162. </xsl:when>
  163. <xsl:otherwise>
  164. <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
  165. <xsl:with-param name="mark" select="$footnote.mark"/>
  166. </xsl:apply-templates>
  167. </xsl:otherwise>
  168. </xsl:choose>
  169. </xsl:when>
  170. <xsl:otherwise>
  171. <xsl:copy-of select="$html"/>
  172. </xsl:otherwise>
  173. </xsl:choose>
  174. </xsl:template>
  175. <!-- ==================================================================== -->
  176. <!--
  177. <xsl:template name="count-element-from">
  178. <xsl:param name="from" select=".."/>
  179. <xsl:param name="to" select="."/>
  180. <xsl:param name="count" select="0"/>
  181. <xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
  182. |$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
  183. <xsl:choose>
  184. <xsl:when test="not($list)">
  185. <xsl:text>-1</xsl:text>
  186. </xsl:when>
  187. <xsl:when test="$list[1] = $to">
  188. <xsl:value-of select="$count + 1"/>
  189. </xsl:when>
  190. <xsl:otherwise>
  191. </xsl:otherwise>
  192. </xsl:choose>
  193. </xsl:template>
  194. -->
  195. <!-- ==================================================================== -->
  196. <xsl:template name="process.footnotes">
  197. <xsl:variable name="footnotes" select=".//footnote"/>
  198. <xsl:variable name="table.footnotes" select=".//tgroup//footnote"/>
  199. <!-- Only bother to do this if there's at least one non-table footnote -->
  200. <xsl:if test="count($footnotes)&gt;count($table.footnotes)">
  201. <div class="footnotes">
  202. <br/>
  203. <hr width="100" align="left"/>
  204. <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
  205. </div>
  206. </xsl:if>
  207. <xsl:if test="$annotation.support != 0 and //annotation">
  208. <div class="annotation-list">
  209. <div class="annotation-nocss">
  210. <p>The following annotations are from this essay. You are seeing
  211. them here because your browser doesn&#8217;t support the user-interface
  212. techniques used to make them appear as &#8216;popups&#8217; on modern browsers.</p>
  213. </div>
  214. <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
  215. </div>
  216. </xsl:if>
  217. </xsl:template>
  218. <xsl:template name="process.chunk.footnotes">
  219. <!-- nop -->
  220. </xsl:template>
  221. <xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">
  222. <xsl:choose>
  223. <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
  224. <div>
  225. <xsl:apply-templates select="." mode="class.attribute"/>
  226. <xsl:apply-templates/>
  227. </div>
  228. </xsl:when>
  229. <xsl:when test="$html.cleanup != 0 and function-available('exsl:node-set')">
  230. <div>
  231. <xsl:apply-templates select="." mode="class.attribute"/>
  232. <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
  233. <xsl:apply-templates select="*[position() &gt; 1]"/>
  234. </div>
  235. </xsl:when>
  236. <xsl:otherwise>
  237. <xsl:message>
  238. <xsl:text>Warning: footnote number may not be generated </xsl:text>
  239. <xsl:text>correctly; </xsl:text>
  240. <xsl:value-of select="local-name(*[1])"/>
  241. <xsl:text> unexpected as first child of footnote.</xsl:text>
  242. </xsl:message>
  243. <div>
  244. <xsl:apply-templates select="." mode="class.attribute"/>
  245. <xsl:apply-templates/>
  246. </div>
  247. </xsl:otherwise>
  248. </xsl:choose>
  249. </xsl:template>
  250. <xsl:template match="tgroup//footnote" mode="process.footnote.mode">
  251. </xsl:template>
  252. <xsl:template match="footnote" mode="table.footnote.mode">
  253. <xsl:call-template name="process.footnote"/>
  254. </xsl:template>
  255. </xsl:stylesheet>