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:d="http://docbook.org/ns/docbook" xmlns:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl d" version="1.0">
3 <!-- ********************************************************************
5 This file is part of the XSL DocBook Stylesheet distribution.
6 See ../README or http://cdn.docbook.org/release/xsl/current/ for
7 copyright and other information.
9 ******************************************************************** -->
11 <!-- This template generates just the footnote marker inline.
12 The footnote text is handled in name="process.footnote".
13 The footnote marker gets an id of @id, while the
14 footnote text gets an id of #ftn.@id. They cross link to each other. -->
15 <xsl:template match="d:footnote">
16 <xsl:variable name="name">
17 <xsl:call-template name="object.id">
18 <xsl:with-param name="conditional" select="0"/>
21 <xsl:variable name="href">
22 <xsl:text>#ftn.</xsl:text>
23 <xsl:value-of select="$name"/>
27 <xsl:apply-templates select="." mode="class.attribute"/>
28 <xsl:if test="$generate.id.attributes = 0">
29 <xsl:attribute name="id">
30 <xsl:value-of select="$name"/>
35 <xsl:apply-templates select="." mode="class.attribute"/>
36 <xsl:call-template name="id.attribute">
37 <xsl:with-param name="conditional" select="0"/>
39 <xsl:text>[</xsl:text>
40 <xsl:apply-templates select="." mode="footnote.number"/>
41 <xsl:text>]</xsl:text>
46 <xsl:template match="d:footnoteref">
47 <xsl:variable name="targets" select="key('id',@linkend)"/>
48 <xsl:variable name="footnote" select="$targets[1]"/>
50 <xsl:if test="not(local-name($footnote) = 'footnote')">
51 <xsl:message terminate="yes">
52 ERROR: A footnoteref element has a linkend that points to an element that is not a footnote.
53 Typically this happens when an id attribute is accidentally applied to the child of a footnote element.
54 target element: <xsl:value-of select="local-name($footnote)"/>
55 linkend/id: <xsl:value-of select="@linkend"/>
59 <xsl:variable name="target.href">
60 <xsl:call-template name="href.target">
61 <xsl:with-param name="object" select="$footnote"/>
65 <xsl:variable name="href">
66 <xsl:value-of select="substring-before($target.href, '#')"/>
67 <xsl:text>#ftn.</xsl:text>
68 <xsl:value-of select="substring-after($target.href, '#')"/>
72 <xsl:apply-templates select="." mode="class.attribute"/>
73 <xsl:call-template name="id.attribute"/>
75 <xsl:apply-templates select="." mode="class.attribute"/>
76 <xsl:text>[</xsl:text>
77 <xsl:apply-templates select="$footnote" mode="footnote.number"/>
78 <xsl:text>]</xsl:text>
83 <xsl:template match="d:footnote" mode="footnote.number">
85 <xsl:when test="string-length(@label) != 0">
86 <xsl:value-of select="@label"/>
88 <xsl:when test="ancestor::d:table or ancestor::d:informaltable">
89 <xsl:variable name="tfnum">
90 <xsl:number level="any" from="d:table|d:informaltable" format="1"/>
94 <xsl:when test="string-length($table.footnote.number.symbols) >= $tfnum">
95 <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
98 <xsl:number level="any" from="d:table | d:informaltable" format="{$table.footnote.number.format}"/>
103 <xsl:variable name="pfoot" select="preceding::d:footnote[not(@label)]"/>
104 <xsl:variable name="ptfoot" select="preceding::d:table//d:footnote | preceding::d:informaltable//d:footnote"/>
105 <xsl:variable name="fnum" select="count($pfoot) - count($ptfoot) + 1"/>
108 <xsl:when test="string-length($footnote.number.symbols) >= $fnum">
109 <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
112 <xsl:number value="$fnum" format="{$footnote.number.format}"/>
119 <!-- ==================================================================== -->
121 <xsl:template match="d:footnote/d:para[1]|d:footnote/d:simpara[1]" priority="2">
122 <!-- this only works if the first thing in a footnote is a para, -->
123 <!-- which is ok, because it usually is. -->
124 <xsl:variable name="href">
125 <xsl:text>#</xsl:text>
126 <xsl:call-template name="object.id">
127 <xsl:with-param name="object" select="ancestor::d:footnote"/>
131 <xsl:call-template name="paragraph">
132 <xsl:with-param name="class">
133 <xsl:if test="@role and $para.propagates.style != 0">
134 <xsl:value-of select="@role"/>
137 <xsl:with-param name="content">
139 <xsl:apply-templates select="." mode="class.attribute"/>
141 <xsl:apply-templates select="." mode="class.attribute"/>
142 <xsl:text>[</xsl:text>
143 <xsl:apply-templates select="ancestor::d:footnote" mode="footnote.number"/>
144 <xsl:text>] </xsl:text>
147 <xsl:apply-templates/>
153 <!-- ==================================================================== -->
155 <xsl:template match="*" mode="footnote.body.number">
156 <xsl:variable name="name">
157 <xsl:text>ftn.</xsl:text>
158 <xsl:call-template name="object.id">
159 <xsl:with-param name="object" select="ancestor::d:footnote"/>
162 <xsl:variable name="href">
163 <xsl:text>#</xsl:text>
164 <xsl:call-template name="object.id">
165 <xsl:with-param name="object" select="ancestor::d:footnote"/>
168 <xsl:variable name="footnote.mark">
170 <xsl:apply-templates select="." mode="class.attribute"/>
172 <xsl:when test="$generate.id.attributes = 0">
173 <xsl:if test="@id or @xml:id">
174 <xsl:attribute name="id">
175 <xsl:value-of select="@id|@xml:id"/>
180 <xsl:call-template name="id.attribute"/>
184 <xsl:text>[</xsl:text>
185 <xsl:apply-templates select="ancestor::d:footnote" mode="footnote.number"/>
186 <xsl:text>] </xsl:text>
191 <xsl:variable name="html">
192 <xsl:apply-templates select="."/>
196 <xsl:when test="$exsl.node.set.available != 0">
197 <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
199 <xsl:when test="$html-nodes//p">
200 <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
201 <xsl:with-param name="mark" select="$footnote.mark"/>
202 </xsl:apply-templates>
205 <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
206 <xsl:with-param name="mark" select="$footnote.mark"/>
207 </xsl:apply-templates>
212 <xsl:copy-of select="$html"/>
217 <!-- ==================================================================== -->
220 <xsl:template name="count-element-from">
221 <xsl:param name="from" select=".."/>
222 <xsl:param name="to" select="."/>
223 <xsl:param name="count" select="0"/>
224 <xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
225 |$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
228 <xsl:when test="not($list)">
229 <xsl:text>-1</xsl:text>
231 <xsl:when test="$list[1] = $to">
232 <xsl:value-of select="$count + 1"/>
240 <!-- ==================================================================== -->
242 <xsl:template name="process.footnotes">
243 <xsl:variable name="footnotes" select=".//d:footnote"/>
244 <xsl:variable name="table.footnotes" select=".//d:table//d:footnote | .//d:informaltable//d:footnote"/>
246 <!-- Only bother to do this if there's at least one non-table footnote -->
247 <xsl:if test="count($footnotes)>count($table.footnotes)">
248 <div class="footnotes">
249 <xsl:call-template name="footnotes.attributes"/>
253 <xsl:when test="$make.clean.html != 0">
254 <xsl:attribute name="class">footnote-hr</xsl:attribute>
256 <xsl:when test="$css.decoration != 0">
257 <xsl:attribute name="style">
258 <xsl:value-of select="concat('width:100; text-align:', $direction.align.start, ';', 'margin-', $direction.align.start, ': 0')"/>
262 <xsl:attribute name="width">100</xsl:attribute>
263 <xsl:attribute name="align"><xsl:value-of select="$direction.align.start"/></xsl:attribute>
267 <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
271 <xsl:if test="$annotation.support != 0 and //d:annotation">
272 <div class="annotation-list">
273 <div class="annotation-nocss">
274 <p>The following annotations are from this essay. You are seeing
275 them here because your browser doesn’t support the user-interface
276 techniques used to make them appear as ‘popups’ on modern browsers.</p>
279 <xsl:apply-templates select="//d:annotation" mode="annotation-popup"/>
284 <xsl:template name="footnotes.attributes">
285 <!-- customizable for footnotes attributes -->
288 <xsl:template name="process.chunk.footnotes">
292 <xsl:template match="d:footnote" name="process.footnote" mode="process.footnote.mode">
293 <xsl:variable name="id">
294 <xsl:text>ftn.</xsl:text>
295 <xsl:call-template name="object.id">
296 <xsl:with-param name="conditional" select="0"/>
301 <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
303 <xsl:call-template name="common.html.attributes"/>
304 <xsl:apply-templates/>
308 <xsl:when test="$html.cleanup != 0 and $exsl.node.set.available != 0">
310 <xsl:call-template name="common.html.attributes"/>
311 <xsl:call-template name="id.attribute"/>
312 <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
313 <xsl:apply-templates select="*[position() > 1]"/>
319 <xsl:text>Warning: footnote number may not be generated </xsl:text>
320 <xsl:text>correctly; </xsl:text>
321 <xsl:value-of select="local-name(*[1])"/>
322 <xsl:text> unexpected as first child of footnote.</xsl:text>
325 <xsl:call-template name="common.html.attributes"/>
326 <xsl:call-template name="id.attribute"/>
327 <xsl:apply-templates/>
333 <xsl:template match="d:table//d:footnote | d:informaltable//d:footnote" mode="process.footnote.mode">
336 <xsl:template match="d:footnote" mode="table.footnote.mode">
337 <xsl:call-template name="process.footnote"/>