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 9665 2012-11-08 14:26:20Z kosek $
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 <!-- This template generates just the footnote marker inline.
17 The footnote text is handled in name="process.footnote".
18 The footnote marker gets an id of @id, while the
19 footnote text gets an id of #ftn.@id. They cross link to each other. -->
20 <xsl:template match="footnote">
21 <xsl:variable name="name">
22 <xsl:call-template name="object.id">
23 <xsl:with-param name="conditional" select="0"/>
26 <xsl:variable name="href">
27 <xsl:text>#ftn.</xsl:text>
28 <xsl:value-of select="$name"/>
32 <xsl:apply-templates select="." mode="class.attribute"/>
33 <xsl:if test="$generate.id.attributes = 0">
34 <xsl:attribute name="id">
35 <xsl:value-of select="$name"/>
40 <xsl:apply-templates select="." mode="class.attribute"/>
41 <xsl:call-template name="id.attribute">
42 <xsl:with-param name="conditional" select="0"/>
44 <xsl:text>[</xsl:text>
45 <xsl:apply-templates select="." mode="footnote.number"/>
46 <xsl:text>]</xsl:text>
51 <xsl:template match="footnoteref">
52 <xsl:variable name="targets" select="key('id',@linkend)"/>
53 <xsl:variable name="footnote" select="$targets[1]"/>
55 <xsl:if test="not(local-name($footnote) = 'footnote')">
56 <xsl:message terminate="yes">
57 ERROR: A footnoteref element has a linkend that points to an element that is not a footnote.
58 Typically this happens when an id attribute is accidentally applied to the child of a footnote element.
59 target element: <xsl:value-of select="local-name($footnote)"/>
60 linkend/id: <xsl:value-of select="@linkend"/>
64 <xsl:variable name="target.href">
65 <xsl:call-template name="href.target">
66 <xsl:with-param name="object" select="$footnote"/>
70 <xsl:variable name="href">
71 <xsl:value-of select="substring-before($target.href, '#')"/>
72 <xsl:text>#ftn.</xsl:text>
73 <xsl:value-of select="substring-after($target.href, '#')"/>
77 <xsl:apply-templates select="." mode="class.attribute"/>
78 <xsl:call-template name="id.attribute"/>
80 <xsl:apply-templates select="." mode="class.attribute"/>
81 <xsl:text>[</xsl:text>
82 <xsl:apply-templates select="$footnote" mode="footnote.number"/>
83 <xsl:text>]</xsl:text>
88 <xsl:template match="footnote" mode="footnote.number">
90 <xsl:when test="string-length(@label) != 0">
91 <xsl:value-of select="@label"/>
93 <xsl:when test="ancestor::table or ancestor::informaltable">
94 <xsl:variable name="tfnum">
95 <xsl:number level="any" from="table|informaltable" format="1"/>
99 <xsl:when test="string-length($table.footnote.number.symbols) >= $tfnum">
100 <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
103 <xsl:number level="any" from="table | informaltable" format="{$table.footnote.number.format}"/>
108 <xsl:variable name="pfoot" select="preceding::footnote[not(@label)]"/>
109 <xsl:variable name="ptfoot" select="preceding::table//footnote | preceding::informaltable//footnote"/>
110 <xsl:variable name="fnum" select="count($pfoot) - count($ptfoot) + 1"/>
113 <xsl:when test="string-length($footnote.number.symbols) >= $fnum">
114 <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
117 <xsl:number value="$fnum" format="{$footnote.number.format}"/>
124 <!-- ==================================================================== -->
126 <xsl:template match="footnote/para[1]|footnote/simpara[1]" priority="2">
127 <!-- this only works if the first thing in a footnote is a para, -->
128 <!-- which is ok, because it usually is. -->
129 <xsl:variable name="href">
130 <xsl:text>#</xsl:text>
131 <xsl:call-template name="object.id">
132 <xsl:with-param name="object" select="ancestor::footnote"/>
136 <xsl:call-template name="paragraph">
137 <xsl:with-param name="class">
138 <xsl:if test="@role and $para.propagates.style != 0">
139 <xsl:value-of select="@role"/>
142 <xsl:with-param name="content">
144 <xsl:apply-templates select="." mode="class.attribute"/>
146 <xsl:apply-templates select="." mode="class.attribute"/>
147 <xsl:text>[</xsl:text>
148 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
149 <xsl:text>] </xsl:text>
152 <xsl:apply-templates/>
158 <!-- ==================================================================== -->
160 <xsl:template match="*" mode="footnote.body.number">
161 <xsl:variable name="name">
162 <xsl:text>ftn.</xsl:text>
163 <xsl:call-template name="object.id">
164 <xsl:with-param name="object" select="ancestor::footnote"/>
167 <xsl:variable name="href">
168 <xsl:text>#</xsl:text>
169 <xsl:call-template name="object.id">
170 <xsl:with-param name="object" select="ancestor::footnote"/>
173 <xsl:variable name="footnote.mark">
175 <xsl:apply-templates select="." mode="class.attribute"/>
177 <xsl:when test="$generate.id.attributes = 0">
178 <xsl:if test="@id or @xml:id">
179 <xsl:attribute name="id">
180 <xsl:value-of select="@id|@xml:id"/>
185 <xsl:call-template name="id.attribute"/>
189 <xsl:text>[</xsl:text>
190 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
191 <xsl:text>] </xsl:text>
196 <xsl:variable name="html">
197 <xsl:apply-templates select="."/>
201 <xsl:when test="$exsl.node.set.available != 0">
202 <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
204 <xsl:when test="$html-nodes//p">
205 <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
206 <xsl:with-param name="mark" select="$footnote.mark"/>
207 </xsl:apply-templates>
210 <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
211 <xsl:with-param name="mark" select="$footnote.mark"/>
212 </xsl:apply-templates>
217 <xsl:copy-of select="$html"/>
222 <!-- ==================================================================== -->
225 <xsl:template name="count-element-from">
226 <xsl:param name="from" select=".."/>
227 <xsl:param name="to" select="."/>
228 <xsl:param name="count" select="0"/>
229 <xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
230 |$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
233 <xsl:when test="not($list)">
234 <xsl:text>-1</xsl:text>
236 <xsl:when test="$list[1] = $to">
237 <xsl:value-of select="$count + 1"/>
245 <!-- ==================================================================== -->
247 <xsl:template name="process.footnotes">
248 <xsl:variable name="footnotes" select=".//footnote"/>
249 <xsl:variable name="table.footnotes" select=".//table//footnote | .//informaltable//footnote"/>
251 <!-- Only bother to do this if there's at least one non-table footnote -->
252 <xsl:if test="count($footnotes)>count($table.footnotes)">
253 <div class="footnotes">
254 <xsl:call-template name="footnotes.attributes"/>
258 <xsl:when test="$make.clean.html != 0">
259 <xsl:attribute name="class">footnote-hr</xsl:attribute>
261 <xsl:when test="$css.decoration != 0">
262 <xsl:attribute name="style">
263 <xsl:value-of select="concat('width:100; text-align:', $direction.align.start, ';', 'margin-', $direction.align.start, ': 0')"/>
267 <xsl:attribute name="width">100</xsl:attribute>
268 <xsl:attribute name="align"><xsl:value-of select="$direction.align.start"/></xsl:attribute>
272 <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
276 <xsl:if test="$annotation.support != 0 and //annotation">
277 <div class="annotation-list">
278 <div class="annotation-nocss">
279 <p>The following annotations are from this essay. You are seeing
280 them here because your browser doesn’t support the user-interface
281 techniques used to make them appear as ‘popups’ on modern browsers.</p>
284 <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
289 <xsl:template name="footnotes.attributes">
290 <!-- customizable for footnotes attributes -->
293 <xsl:template name="process.chunk.footnotes">
297 <xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">
298 <xsl:variable name="id">
299 <xsl:text>ftn.</xsl:text>
300 <xsl:call-template name="object.id">
301 <xsl:with-param name="conditional" select="0"/>
306 <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
308 <xsl:call-template name="common.html.attributes"/>
309 <xsl:apply-templates/>
313 <xsl:when test="$html.cleanup != 0 and $exsl.node.set.available != 0">
315 <xsl:call-template name="common.html.attributes"/>
316 <xsl:call-template name="id.attribute"/>
317 <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
318 <xsl:apply-templates select="*[position() > 1]"/>
324 <xsl:text>Warning: footnote number may not be generated </xsl:text>
325 <xsl:text>correctly; </xsl:text>
326 <xsl:value-of select="local-name(*[1])"/>
327 <xsl:text> unexpected as first child of footnote.</xsl:text>
330 <xsl:call-template name="common.html.attributes"/>
331 <xsl:call-template name="id.attribute"/>
332 <xsl:apply-templates/>
338 <xsl:template match="table//footnote | informaltable//footnote" mode="process.footnote.mode">
341 <xsl:template match="footnote" mode="table.footnote.mode">
342 <xsl:call-template name="process.footnote"/>