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 8421 2009-05-04 07:49:49Z 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::tgroup">
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::tgroup">
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="tgroup" format="{$table.footnote.number.format}"/>
104 <xsl:variable name="pfoot" select="preceding::footnote[not(@label)]"/>
105 <xsl:variable name="ptfoot" select="preceding::tgroup//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="locale.html.attributes"/>
139 <xsl:if test="@role and $para.propagates.style != 0">
140 <xsl:apply-templates select="." mode="class.attribute">
141 <xsl:with-param name="class" select="@role"/>
142 </xsl:apply-templates>
145 <xsl:text>[</xsl:text>
146 <a id="{$name}" href="{$href}">
147 <xsl:apply-templates select="." mode="class.attribute"/>
148 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
150 <xsl:text>] </xsl:text>
152 <xsl:apply-templates/>
156 <!-- ==================================================================== -->
158 <xsl:template match="*" mode="footnote.body.number">
159 <xsl:variable name="name">
160 <xsl:text>ftn.</xsl:text>
161 <xsl:call-template name="object.id">
162 <xsl:with-param name="object" select="ancestor::footnote"/>
165 <xsl:variable name="href">
166 <xsl:text>#</xsl:text>
167 <xsl:call-template name="object.id">
168 <xsl:with-param name="object" select="ancestor::footnote"/>
171 <xsl:variable name="footnote.mark">
173 <xsl:text>[</xsl:text>
174 <a id="{$name}" href="{$href}">
175 <xsl:apply-templates select="." mode="class.attribute"/>
176 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
178 <xsl:text>] </xsl:text>
182 <xsl:variable name="html">
183 <xsl:apply-templates select="."/>
187 <xsl:when test="$exsl.node.set.available != 0">
188 <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
190 <xsl:when test="$html-nodes//p">
191 <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
192 <xsl:with-param name="mark" select="$footnote.mark"/>
193 </xsl:apply-templates>
196 <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
197 <xsl:with-param name="mark" select="$footnote.mark"/>
198 </xsl:apply-templates>
203 <xsl:copy-of select="$html"/>
208 <!-- ==================================================================== -->
211 <xsl:template name="count-element-from">
212 <xsl:param name="from" select=".."/>
213 <xsl:param name="to" select="."/>
214 <xsl:param name="count" select="0"/>
215 <xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
216 |$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
219 <xsl:when test="not($list)">
220 <xsl:text>-1</xsl:text>
222 <xsl:when test="$list[1] = $to">
223 <xsl:value-of select="$count + 1"/>
231 <!-- ==================================================================== -->
233 <xsl:template name="process.footnotes">
234 <xsl:variable name="footnotes" select=".//footnote"/>
235 <xsl:variable name="table.footnotes" select=".//tgroup//footnote"/>
237 <!-- Only bother to do this if there's at least one non-table footnote -->
238 <xsl:if test="count($footnotes)>count($table.footnotes)">
239 <div class="footnotes">
241 <hr width="100" align="{$direction.align.start}"/>
242 <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
246 <xsl:if test="$annotation.support != 0 and //annotation">
247 <div class="annotation-list">
248 <div class="annotation-nocss">
249 <p>The following annotations are from this essay. You are seeing
250 them here because your browser doesn’t support the user-interface
251 techniques used to make them appear as ‘popups’ on modern browsers.</p>
254 <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
259 <xsl:template name="process.chunk.footnotes">
263 <xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">
265 <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
267 <xsl:call-template name="common.html.attributes"/>
268 <xsl:apply-templates/>
272 <xsl:when test="$html.cleanup != 0 and $exsl.node.set.available != 0">
274 <xsl:call-template name="common.html.attributes"/>
275 <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
276 <xsl:apply-templates select="*[position() > 1]"/>
282 <xsl:text>Warning: footnote number may not be generated </xsl:text>
283 <xsl:text>correctly; </xsl:text>
284 <xsl:value-of select="local-name(*[1])"/>
285 <xsl:text> unexpected as first child of footnote.</xsl:text>
288 <xsl:call-template name="common.html.attributes"/>
289 <xsl:apply-templates/>
295 <xsl:template match="tgroup//footnote" mode="process.footnote.mode">
298 <xsl:template match="footnote" mode="table.footnote.mode">
299 <xsl:call-template name="process.footnote"/>