1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
|
<?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook"
xmlns:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl d" version="1.0">
<!-- ********************************************************************
$Id: footnote.xsl 9665 2012-11-08 14:26:20Z kosek $
********************************************************************
This file is part of the XSL DocBook Stylesheet distribution.
See ../README or http://docbook.sf.net/release/xsl/current/ for
copyright and other information.
******************************************************************** -->
<!-- This template generates just the footnote marker inline.
The footnote text is handled in name="process.footnote".
The footnote marker gets an id of @id, while the
footnote text gets an id of #ftn.@id. They cross link to each other. -->
<xsl:template match="d:footnote">
<xsl:variable name="name">
<xsl:call-template name="object.id">
<xsl:with-param name="conditional" select="0"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="href">
<xsl:text>#ftn.</xsl:text>
<xsl:value-of select="$name"/>
</xsl:variable>
<a href="{$href}">
<xsl:apply-templates select="." mode="class.attribute"/>
<xsl:if test="$generate.id.attributes = 0">
<xsl:attribute name="id">
<xsl:value-of select="$name"/>
</xsl:attribute>
</xsl:if>
<sup>
<xsl:apply-templates select="." mode="class.attribute"/>
<xsl:call-template name="id.attribute">
<xsl:with-param name="conditional" select="0"/>
</xsl:call-template>
<xsl:text>[</xsl:text>
<xsl:apply-templates select="." mode="footnote.number"/>
<xsl:text>]</xsl:text>
</sup>
</a>
</xsl:template>
<xsl:template match="d:footnoteref">
<xsl:variable name="targets" select="key('id',@linkend)"/>
<xsl:variable name="footnote" select="$targets[1]"/>
<xsl:if test="not(local-name($footnote) = 'footnote')">
<xsl:message terminate="yes">
ERROR: A footnoteref element has a linkend that points to an element that is not a footnote.
Typically this happens when an id attribute is accidentally applied to the child of a footnote element.
target element: <xsl:value-of select="local-name($footnote)"/>
linkend/id: <xsl:value-of select="@linkend"/>
</xsl:message>
</xsl:if>
<xsl:variable name="target.href">
<xsl:call-template name="href.target">
<xsl:with-param name="object" select="$footnote"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="href">
<xsl:value-of select="substring-before($target.href, '#')"/>
<xsl:text>#ftn.</xsl:text>
<xsl:value-of select="substring-after($target.href, '#')"/>
</xsl:variable>
<a href="{$href}">
<xsl:apply-templates select="." mode="class.attribute"/>
<xsl:call-template name="id.attribute"/>
<sup>
<xsl:apply-templates select="." mode="class.attribute"/>
<xsl:text>[</xsl:text>
<xsl:apply-templates select="$footnote" mode="footnote.number"/>
<xsl:text>]</xsl:text>
</sup>
</a>
</xsl:template>
<xsl:template match="d:footnote" mode="footnote.number">
<xsl:choose>
<xsl:when test="string-length(@label) != 0">
<xsl:value-of select="@label"/>
</xsl:when>
<xsl:when test="ancestor::d:table or ancestor::d:informaltable">
<xsl:variable name="tfnum">
<xsl:number level="any" from="d:table|d:informaltable" format="1"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($table.footnote.number.symbols) >= $tfnum">
<xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" from="d:table | d:informaltable" format="{$table.footnote.number.format}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="pfoot" select="preceding::d:footnote[not(@label)]"/>
<xsl:variable name="ptfoot" select="preceding::d:table//d:footnote | preceding::d:informaltable//d:footnote"/>
<xsl:variable name="fnum" select="count($pfoot) - count($ptfoot) + 1"/>
<xsl:choose>
<xsl:when test="string-length($footnote.number.symbols) >= $fnum">
<xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:number value="$fnum" format="{$footnote.number.format}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template match="d:footnote/d:para[1]|d:footnote/d:simpara[1]" priority="2">
<!-- this only works if the first thing in a footnote is a para, -->
<!-- which is ok, because it usually is. -->
<xsl:variable name="href">
<xsl:text>#</xsl:text>
<xsl:call-template name="object.id">
<xsl:with-param name="object" select="ancestor::d:footnote"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="paragraph">
<xsl:with-param name="class">
<xsl:if test="@role and $para.propagates.style != 0">
<xsl:value-of select="@role"/>
</xsl:if>
</xsl:with-param>
<xsl:with-param name="content">
<a href="{$href}">
<xsl:apply-templates select="." mode="class.attribute"/>
<sup>
<xsl:apply-templates select="." mode="class.attribute"/>
<xsl:text>[</xsl:text>
<xsl:apply-templates select="ancestor::d:footnote" mode="footnote.number"/>
<xsl:text>] </xsl:text>
</sup>
</a>
<xsl:apply-templates/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template match="*" mode="footnote.body.number">
<xsl:variable name="name">
<xsl:text>ftn.</xsl:text>
<xsl:call-template name="object.id">
<xsl:with-param name="object" select="ancestor::d:footnote"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="href">
<xsl:text>#</xsl:text>
<xsl:call-template name="object.id">
<xsl:with-param name="object" select="ancestor::d:footnote"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="footnote.mark">
<a href="{$href}">
<xsl:apply-templates select="." mode="class.attribute"/>
<xsl:choose>
<xsl:when test="$generate.id.attributes = 0">
<xsl:if test="@id or @xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@id|@xml:id"/>
</xsl:attribute>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="id.attribute"/>
</xsl:otherwise>
</xsl:choose>
<sup>
<xsl:text>[</xsl:text>
<xsl:apply-templates select="ancestor::d:footnote" mode="footnote.number"/>
<xsl:text>] </xsl:text>
</sup>
</a>
</xsl:variable>
<xsl:variable name="html">
<xsl:apply-templates select="."/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$exsl.node.set.available != 0">
<xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
<xsl:choose>
<xsl:when test="$html-nodes//p">
<xsl:apply-templates select="$html-nodes" mode="insert.html.p">
<xsl:with-param name="mark" select="$footnote.mark"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$html-nodes" mode="insert.html.text">
<xsl:with-param name="mark" select="$footnote.mark"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$html"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ==================================================================== -->
<!--
<xsl:template name="count-element-from">
<xsl:param name="from" select=".."/>
<xsl:param name="to" select="."/>
<xsl:param name="count" select="0"/>
<xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
|$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
<xsl:choose>
<xsl:when test="not($list)">
<xsl:text>-1</xsl:text>
</xsl:when>
<xsl:when test="$list[1] = $to">
<xsl:value-of select="$count + 1"/>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-->
<!-- ==================================================================== -->
<xsl:template name="process.footnotes">
<xsl:variable name="footnotes" select=".//d:footnote"/>
<xsl:variable name="table.footnotes" select=".//d:table//d:footnote | .//d:informaltable//d:footnote"/>
<!-- Only bother to do this if there's at least one non-table footnote -->
<xsl:if test="count($footnotes)>count($table.footnotes)">
<div class="footnotes">
<xsl:call-template name="footnotes.attributes"/>
<br/>
<hr/>
<xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
</div>
</xsl:if>
<xsl:if test="$annotation.support != 0 and //d:annotation">
<div class="annotation-list">
<div class="annotation-nocss">
<p>The following annotations are from this essay. You are seeing
them here because your browser doesn’t support the user-interface
techniques used to make them appear as ‘popups’ on modern browsers.</p>
</div>
<xsl:apply-templates select="//d:annotation" mode="annotation-popup"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template name="footnotes.attributes">
<!-- customizable for footnotes attributes -->
</xsl:template>
<xsl:template name="process.chunk.footnotes">
<!-- nop -->
</xsl:template>
<xsl:template match="d:footnote" name="process.footnote" mode="process.footnote.mode">
<xsl:variable name="id">
<xsl:text>ftn.</xsl:text>
<xsl:call-template name="object.id">
<xsl:with-param name="conditional" select="0"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
<div id="{$id}">
<xsl:call-template name="common.html.attributes"/>
<xsl:apply-templates/>
</div>
</xsl:when>
<xsl:when test="$html.cleanup != 0 and $exsl.node.set.available != 0">
<div id="{$id}">
<xsl:call-template name="common.html.attributes"/>
<xsl:call-template name="id.attribute"/>
<xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
<xsl:apply-templates select="*[position() > 1]"/>
</div>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>Warning: footnote number may not be generated </xsl:text>
<xsl:text>correctly; </xsl:text>
<xsl:value-of select="local-name(*[1])"/>
<xsl:text> unexpected as first child of footnote.</xsl:text>
</xsl:message>
<div id="{$id}">
<xsl:call-template name="common.html.attributes"/>
<xsl:call-template name="id.attribute"/>
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="d:table//d:footnote | d:informaltable//d:footnote" mode="process.footnote.mode">
</xsl:template>
<xsl:template match="d:footnote" mode="table.footnote.mode">
<xsl:call-template name="process.footnote"/>
</xsl:template>
</xsl:stylesheet>
|