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:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl" version="1.0">
6 <!-- ********************************************************************
7 $Id: footnote.xsl 8812 2010-08-09 20:51:51Z bobstayton $
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <xsl:template match="footnote">
17 <xsl:variable name="name">
18 <xsl:call-template name="object.id"/>
20 <xsl:variable name="href">
21 <xsl:text>#ftn.</xsl:text>
22 <xsl:call-template name="object.id"/>
26 <xsl:when test="ancestor::table or ancestor::informaltable">
28 <xsl:text>[</xsl:text>
29 <a id="{$name}" href="{$href}">
30 <xsl:apply-templates select="." mode="class.attribute"/>
31 <xsl:apply-templates select="." mode="footnote.number"/>
33 <xsl:text>]</xsl:text>
38 <xsl:text>[</xsl:text>
39 <a id="{$name}" href="{$href}">
40 <xsl:apply-templates select="." mode="class.attribute"/>
41 <xsl:apply-templates select="." mode="footnote.number"/>
43 <xsl:text>]</xsl:text>
49 <xsl:template match="footnoteref">
50 <xsl:variable name="targets" select="key('id',@linkend)"/>
51 <xsl:variable name="footnote" select="$targets[1]"/>
53 <xsl:if test="not(local-name($footnote) = 'footnote')">
54 <xsl:message terminate="yes">
55 ERROR: A footnoteref element has a linkend that points to an element that is not a footnote.
56 Typically this happens when an id attribute is accidentally applied to the child of a footnote element.
57 target element: <xsl:value-of select="local-name($footnote)"/>
58 linkend/id: <xsl:value-of select="@linkend"/>
62 <xsl:variable name="target.href">
63 <xsl:call-template name="href.target">
64 <xsl:with-param name="object" select="$footnote"/>
68 <xsl:variable name="href">
69 <xsl:value-of select="substring-before($target.href, '#')"/>
70 <xsl:text>#ftn.</xsl:text>
71 <xsl:value-of select="substring-after($target.href, '#')"/>
75 <xsl:text>[</xsl:text>
77 <xsl:apply-templates select="." mode="class.attribute"/>
78 <xsl:apply-templates select="$footnote" mode="footnote.number"/>
80 <xsl:text>]</xsl:text>
84 <xsl:template match="footnote" mode="footnote.number">
86 <xsl:when test="string-length(@label) != 0">
87 <xsl:value-of select="@label"/>
89 <xsl:when test="ancestor::table or ancestor::informaltable">
90 <xsl:variable name="tfnum">
91 <xsl:number level="any" from="table|informaltable" format="1"/>
95 <xsl:when test="string-length($table.footnote.number.symbols) >= $tfnum">
96 <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
99 <xsl:number level="any" from="table | informaltable" format="{$table.footnote.number.format}"/>
104 <xsl:variable name="pfoot" select="preceding::footnote[not(@label)]"/>
105 <xsl:variable name="ptfoot" select="preceding::table//footnote | preceding::informaltable//footnote"/>
106 <xsl:variable name="fnum" select="count($pfoot) - count($ptfoot) + 1"/>
109 <xsl:when test="string-length($footnote.number.symbols) >= $fnum">
110 <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
113 <xsl:number value="$fnum" format="{$footnote.number.format}"/>
120 <!-- ==================================================================== -->
122 <xsl:template match="footnote/para[1]|footnote/simpara[1]" priority="2">
123 <!-- this only works if the first thing in a footnote is a para, -->
124 <!-- which is ok, because it usually is. -->
125 <xsl:variable name="name">
126 <xsl:text>ftn.</xsl:text>
127 <xsl:call-template name="object.id">
128 <xsl:with-param name="object" select="ancestor::footnote"/>
131 <xsl:variable name="href">
132 <xsl:text>#</xsl:text>
133 <xsl:call-template name="object.id">
134 <xsl:with-param name="object" select="ancestor::footnote"/>
138 <xsl:call-template name="paragraph">
139 <xsl:with-param name="class">
140 <xsl:if test="@role and $para.propagates.style != 0">
141 <xsl:value-of select="@role"/>
144 <xsl:with-param name="content">
146 <xsl:text>[</xsl:text>
147 <a id="{$name}" href="{$href}">
148 <xsl:apply-templates select="." mode="class.attribute"/>
149 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
151 <xsl:text>] </xsl:text>
153 <xsl:apply-templates/>
159 <!-- ==================================================================== -->
161 <xsl:template match="*" mode="footnote.body.number">
162 <xsl:variable name="name">
163 <xsl:text>ftn.</xsl:text>
164 <xsl:call-template name="object.id">
165 <xsl:with-param name="object" select="ancestor::footnote"/>
168 <xsl:variable name="href">
169 <xsl:text>#</xsl:text>
170 <xsl:call-template name="object.id">
171 <xsl:with-param name="object" select="ancestor::footnote"/>
174 <xsl:variable name="footnote.mark">
176 <xsl:text>[</xsl:text>
177 <a id="{$name}" href="{$href}">
178 <xsl:apply-templates select="." mode="class.attribute"/>
179 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
181 <xsl:text>] </xsl:text>
185 <xsl:variable name="html">
186 <xsl:apply-templates select="."/>
190 <xsl:when test="$exsl.node.set.available != 0">
191 <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
193 <xsl:when test="$html-nodes//p">
194 <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
195 <xsl:with-param name="mark" select="$footnote.mark"/>
196 </xsl:apply-templates>
199 <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
200 <xsl:with-param name="mark" select="$footnote.mark"/>
201 </xsl:apply-templates>
206 <xsl:copy-of select="$html"/>
211 <!-- ==================================================================== -->
214 <xsl:template name="count-element-from">
215 <xsl:param name="from" select=".."/>
216 <xsl:param name="to" select="."/>
217 <xsl:param name="count" select="0"/>
218 <xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
219 |$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
222 <xsl:when test="not($list)">
223 <xsl:text>-1</xsl:text>
225 <xsl:when test="$list[1] = $to">
226 <xsl:value-of select="$count + 1"/>
234 <!-- ==================================================================== -->
236 <xsl:template name="process.footnotes">
237 <xsl:variable name="footnotes" select=".//footnote"/>
238 <xsl:variable name="table.footnotes" select=".//table//footnote | .//informaltable//footnote"/>
240 <!-- Only bother to do this if there's at least one non-table footnote -->
241 <xsl:if test="count($footnotes)>count($table.footnotes)">
242 <div class="footnotes">
245 <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
249 <xsl:if test="$annotation.support != 0 and //annotation">
250 <div class="annotation-list">
251 <div class="annotation-nocss">
252 <p>The following annotations are from this essay. You are seeing
253 them here because your browser doesn’t support the user-interface
254 techniques used to make them appear as ‘popups’ on modern browsers.</p>
257 <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
262 <xsl:template name="process.chunk.footnotes">
266 <xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">
268 <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
270 <xsl:call-template name="common.html.attributes"/>
271 <xsl:apply-templates/>
275 <xsl:when test="$html.cleanup != 0 and $exsl.node.set.available != 0">
277 <xsl:call-template name="common.html.attributes"/>
278 <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
279 <xsl:apply-templates select="*[position() > 1]"/>
285 <xsl:text>Warning: footnote number may not be generated </xsl:text>
286 <xsl:text>correctly; </xsl:text>
287 <xsl:value-of select="local-name(*[1])"/>
288 <xsl:text> unexpected as first child of footnote.</xsl:text>
291 <xsl:call-template name="common.html.attributes"/>
292 <xsl:apply-templates/>
298 <xsl:template match="table//footnote | informaltable//footnote" mode="process.footnote.mode">
301 <xsl:template match="footnote" mode="table.footnote.mode">
302 <xsl:call-template name="process.footnote"/>