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