2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
3 xmlns:
exsl=
"http://exslt.org/common"
4 exclude-result-prefixes=
"exsl"
7 <!-- ********************************************************************
8 $Id: footnote.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
13 and other information.
15 ******************************************************************** -->
17 <xsl:template match=
"footnote">
18 <xsl:variable name=
"name">
19 <xsl:call-template name=
"object.id"/>
21 <xsl:variable name=
"href">
22 <xsl:text>#ftn.
</xsl:text>
23 <xsl:call-template name=
"object.id"/>
27 <xsl:when test=
"ancestor::tgroup">
29 <xsl:text>[
</xsl:text>
30 <a name=
"{$name}" href=
"{$href}">
31 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
32 <xsl:apply-templates select=
"." mode=
"footnote.number"/>
34 <xsl:text>]
</xsl:text>
39 <xsl:text>[
</xsl:text>
40 <a name=
"{$name}" href=
"{$href}">
41 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
42 <xsl:apply-templates select=
"." mode=
"footnote.number"/>
44 <xsl:text>]
</xsl:text>
50 <xsl:template match=
"footnoteref">
51 <xsl:variable name=
"targets" select=
"key('id',@linkend)"/>
52 <xsl:variable name=
"footnote" select=
"$targets[1]"/>
53 <xsl:variable name=
"href">
54 <xsl:text>#ftn.
</xsl:text>
55 <xsl:call-template name=
"object.id">
56 <xsl:with-param name=
"object" select=
"$footnote"/>
60 <xsl:text>[
</xsl:text>
62 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
63 <xsl:apply-templates select=
"$footnote" mode=
"footnote.number"/>
65 <xsl:text>]
</xsl:text>
69 <xsl:template match=
"footnote" mode=
"footnote.number">
71 <xsl:when test=
"string-length(@label) != 0">
72 <xsl:value-of select=
"@label"/>
74 <xsl:when test=
"ancestor::tgroup">
75 <xsl:variable name=
"tfnum">
76 <xsl:number level=
"any" from=
"table|informaltable" format=
"1"/>
80 <xsl:when test=
"string-length($table.footnote.number.symbols) >= $tfnum">
81 <xsl:value-of select=
"substring($table.footnote.number.symbols, $tfnum, 1)"/>
84 <xsl:number level=
"any" from=
"tgroup"
85 format=
"{$table.footnote.number.format}"/>
90 <xsl:variable name=
"pfoot" select=
"preceding::footnote[not(@label)]"/>
91 <xsl:variable name=
"ptfoot" select=
"preceding::tgroup//footnote"/>
92 <xsl:variable name=
"fnum" select=
"count($pfoot) - count($ptfoot) + 1"/>
95 <xsl:when test=
"string-length($footnote.number.symbols) >= $fnum">
96 <xsl:value-of select=
"substring($footnote.number.symbols, $fnum, 1)"/>
99 <xsl:number value=
"$fnum" format=
"{$footnote.number.format}"/>
106 <!-- ==================================================================== -->
108 <xsl:template match=
"footnote/para[1]|footnote/simpara[1]" priority=
"2">
109 <!-- this only works if the first thing in a footnote is a para, -->
110 <!-- which is ok, because it usually is. -->
111 <xsl:variable name=
"name">
112 <xsl:text>ftn.
</xsl:text>
113 <xsl:call-template name=
"object.id">
114 <xsl:with-param name=
"object" select=
"ancestor::footnote"/>
117 <xsl:variable name=
"href">
118 <xsl:text>#
</xsl:text>
119 <xsl:call-template name=
"object.id">
120 <xsl:with-param name=
"object" select=
"ancestor::footnote"/>
124 <xsl:if test=
"@role and $para.propagates.style != 0">
125 <xsl:apply-templates select=
"." mode=
"class.attribute">
126 <xsl:with-param name=
"class" select=
"@role"/>
127 </xsl:apply-templates>
130 <xsl:text>[
</xsl:text>
131 <a name=
"{$name}" href=
"{$href}">
132 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
133 <xsl:apply-templates select=
"ancestor::footnote"
134 mode=
"footnote.number"/>
136 <xsl:text>]
</xsl:text>
138 <xsl:apply-templates/>
142 <!-- ==================================================================== -->
144 <xsl:template match=
"*" mode=
"footnote.body.number">
145 <xsl:variable name=
"name">
146 <xsl:text>ftn.
</xsl:text>
147 <xsl:call-template name=
"object.id">
148 <xsl:with-param name=
"object" select=
"ancestor::footnote"/>
151 <xsl:variable name=
"href">
152 <xsl:text>#
</xsl:text>
153 <xsl:call-template name=
"object.id">
154 <xsl:with-param name=
"object" select=
"ancestor::footnote"/>
157 <xsl:variable name=
"footnote.mark">
159 <xsl:text>[
</xsl:text>
160 <a name=
"{$name}" href=
"{$href}">
161 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
162 <xsl:apply-templates select=
"ancestor::footnote"
163 mode=
"footnote.number"/>
165 <xsl:text>]
</xsl:text>
169 <xsl:variable name=
"html">
170 <xsl:apply-templates select=
"."/>
174 <xsl:when test=
"function-available('exsl:node-set')">
175 <xsl:variable name=
"html-nodes" select=
"exsl:node-set($html)"/>
177 <xsl:when test=
"$html-nodes//p">
178 <xsl:apply-templates select=
"$html-nodes" mode=
"insert.html.p">
179 <xsl:with-param name=
"mark" select=
"$footnote.mark"/>
180 </xsl:apply-templates>
183 <xsl:apply-templates select=
"$html-nodes" mode=
"insert.html.text">
184 <xsl:with-param name=
"mark" select=
"$footnote.mark"/>
185 </xsl:apply-templates>
190 <xsl:copy-of select=
"$html"/>
195 <!-- ==================================================================== -->
198 <xsl:template name="count-element-from">
199 <xsl:param name="from" select=".."/>
200 <xsl:param name="to" select="."/>
201 <xsl:param name="count" select="0"/>
202 <xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
203 |$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
206 <xsl:when test="not($list)">
207 <xsl:text>-1</xsl:text>
209 <xsl:when test="$list[1] = $to">
210 <xsl:value-of select="$count + 1"/>
218 <!-- ==================================================================== -->
220 <xsl:template name=
"process.footnotes">
221 <xsl:variable name=
"footnotes" select=
".//footnote"/>
222 <xsl:variable name=
"table.footnotes"
223 select=
".//tgroup//footnote"/>
225 <!-- Only bother to do this if there's at least one non-table footnote -->
226 <xsl:if test=
"count($footnotes)>count($table.footnotes)">
227 <div class=
"footnotes">
229 <hr width=
"100" align=
"left"/>
230 <xsl:apply-templates select=
"$footnotes" mode=
"process.footnote.mode"/>
234 <xsl:if test=
"$annotation.support != 0 and //annotation">
235 <div class=
"annotation-list">
236 <div class=
"annotation-nocss">
237 <p>The following annotations are from this essay. You are seeing
238 them here because your browser doesn’t support the user-interface
239 techniques used to make them appear as ‘popups’ on modern browsers.
</p>
242 <xsl:apply-templates select=
"//annotation"
243 mode=
"annotation-popup"/>
248 <xsl:template name=
"process.chunk.footnotes">
252 <xsl:template match=
"footnote" name=
"process.footnote" mode=
"process.footnote.mode">
254 <xsl:when test=
"local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
256 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
257 <xsl:apply-templates/>
261 <xsl:when test=
"$html.cleanup != 0 and function-available('exsl:node-set')">
263 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
264 <xsl:apply-templates select=
"*[1]" mode=
"footnote.body.number"/>
265 <xsl:apply-templates select=
"*[position() > 1]"/>
271 <xsl:text>Warning: footnote number may not be generated
</xsl:text>
272 <xsl:text>correctly;
</xsl:text>
273 <xsl:value-of select=
"local-name(*[1])"/>
274 <xsl:text> unexpected as first child of footnote.
</xsl:text>
277 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
278 <xsl:apply-templates/>
284 <xsl:template match=
"tgroup//footnote"
285 mode=
"process.footnote.mode">
288 <xsl:template match=
"footnote" mode=
"table.footnote.mode">
289 <xsl:call-template name=
"process.footnote"/>