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:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl" version="1.0">
|
---|
2 |
|
---|
3 | <!-- ********************************************************************
|
---|
4 | $Id: footnote.xsl 9665 2012-11-08 14:26:20Z kosek $
|
---|
5 | ********************************************************************
|
---|
6 |
|
---|
7 | This file is part of the XSL DocBook Stylesheet distribution.
|
---|
8 | See ../README or http://docbook.sf.net/release/xsl/current/ for
|
---|
9 | copyright and other information.
|
---|
10 |
|
---|
11 | ******************************************************************** -->
|
---|
12 |
|
---|
13 | <!-- This template generates just the footnote marker inline.
|
---|
14 | The footnote text is handled in name="process.footnote".
|
---|
15 | The footnote marker gets an id of @id, while the
|
---|
16 | footnote text gets an id of #ftn.@id. They cross link to each other. -->
|
---|
17 | <xsl:template match="footnote">
|
---|
18 | <xsl:variable name="name">
|
---|
19 | <xsl:call-template name="object.id">
|
---|
20 | <xsl:with-param name="conditional" select="0"/>
|
---|
21 | </xsl:call-template>
|
---|
22 | </xsl:variable>
|
---|
23 | <xsl:variable name="href">
|
---|
24 | <xsl:text>#ftn.</xsl:text>
|
---|
25 | <xsl:value-of select="$name"/>
|
---|
26 | </xsl:variable>
|
---|
27 |
|
---|
28 | <a href="{$href}">
|
---|
29 | <xsl:apply-templates select="." mode="class.attribute"/>
|
---|
30 | <xsl:if test="$generate.id.attributes = 0">
|
---|
31 | <xsl:attribute name="id">
|
---|
32 | <xsl:value-of select="$name"/>
|
---|
33 | </xsl:attribute>
|
---|
34 | </xsl:if>
|
---|
35 |
|
---|
36 | <sup>
|
---|
37 | <xsl:apply-templates select="." mode="class.attribute"/>
|
---|
38 | <xsl:call-template name="id.attribute">
|
---|
39 | <xsl:with-param name="conditional" select="0"/>
|
---|
40 | </xsl:call-template>
|
---|
41 | <xsl:text>[</xsl:text>
|
---|
42 | <xsl:apply-templates select="." mode="footnote.number"/>
|
---|
43 | <xsl:text>]</xsl:text>
|
---|
44 | </sup>
|
---|
45 | </a>
|
---|
46 | </xsl:template>
|
---|
47 |
|
---|
48 | <xsl:template match="footnoteref">
|
---|
49 | <xsl:variable name="targets" select="key('id',@linkend)"/>
|
---|
50 | <xsl:variable name="footnote" select="$targets[1]"/>
|
---|
51 |
|
---|
52 | <xsl:if test="not(local-name($footnote) = 'footnote')">
|
---|
53 | <xsl:message terminate="yes">
|
---|
54 | ERROR: A footnoteref element has a linkend that points to an element that is not a footnote.
|
---|
55 | Typically this happens when an id attribute is accidentally applied to the child of a footnote element.
|
---|
56 | target element: <xsl:value-of select="local-name($footnote)"/>
|
---|
57 | linkend/id: <xsl:value-of select="@linkend"/>
|
---|
58 | </xsl:message>
|
---|
59 | </xsl:if>
|
---|
60 |
|
---|
61 | <xsl:variable name="target.href">
|
---|
62 | <xsl:call-template name="href.target">
|
---|
63 | <xsl:with-param name="object" select="$footnote"/>
|
---|
64 | </xsl:call-template>
|
---|
65 | </xsl:variable>
|
---|
66 |
|
---|
67 | <xsl:variable name="href">
|
---|
68 | <xsl:value-of select="substring-before($target.href, '#')"/>
|
---|
69 | <xsl:text>#ftn.</xsl:text>
|
---|
70 | <xsl:value-of select="substring-after($target.href, '#')"/>
|
---|
71 | </xsl:variable>
|
---|
72 |
|
---|
73 | <a href="{$href}">
|
---|
74 | <xsl:apply-templates select="." mode="class.attribute"/>
|
---|
75 | <xsl:call-template name="id.attribute"/>
|
---|
76 | <sup>
|
---|
77 | <xsl:apply-templates select="." mode="class.attribute"/>
|
---|
78 | <xsl:text>[</xsl:text>
|
---|
79 | <xsl:apply-templates select="$footnote" mode="footnote.number"/>
|
---|
80 | <xsl:text>]</xsl:text>
|
---|
81 | </sup>
|
---|
82 | </a>
|
---|
83 | </xsl:template>
|
---|
84 |
|
---|
85 | <xsl:template match="footnote" mode="footnote.number">
|
---|
86 | <xsl:choose>
|
---|
87 | <xsl:when test="string-length(@label) != 0">
|
---|
88 | <xsl:value-of select="@label"/>
|
---|
89 | </xsl:when>
|
---|
90 | <xsl:when test="ancestor::table or ancestor::informaltable">
|
---|
91 | <xsl:variable name="tfnum">
|
---|
92 | <xsl:number level="any" from="table|informaltable" format="1"/>
|
---|
93 | </xsl:variable>
|
---|
94 |
|
---|
95 | <xsl:choose>
|
---|
96 | <xsl:when test="string-length($table.footnote.number.symbols) >= $tfnum">
|
---|
97 | <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
|
---|
98 | </xsl:when>
|
---|
99 | <xsl:otherwise>
|
---|
100 | <xsl:number level="any" from="table | informaltable" format="{$table.footnote.number.format}"/>
|
---|
101 | </xsl:otherwise>
|
---|
102 | </xsl:choose>
|
---|
103 | </xsl:when>
|
---|
104 | <xsl:otherwise>
|
---|
105 | <xsl:variable name="pfoot" select="preceding::footnote[not(@label)]"/>
|
---|
106 | <xsl:variable name="ptfoot" select="preceding::table//footnote | preceding::informaltable//footnote"/>
|
---|
107 | <xsl:variable name="fnum" select="count($pfoot) - count($ptfoot) + 1"/>
|
---|
108 |
|
---|
109 | <xsl:choose>
|
---|
110 | <xsl:when test="string-length($footnote.number.symbols) >= $fnum">
|
---|
111 | <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
|
---|
112 | </xsl:when>
|
---|
113 | <xsl:otherwise>
|
---|
114 | <xsl:number value="$fnum" format="{$footnote.number.format}"/>
|
---|
115 | </xsl:otherwise>
|
---|
116 | </xsl:choose>
|
---|
117 | </xsl:otherwise>
|
---|
118 | </xsl:choose>
|
---|
119 | </xsl:template>
|
---|
120 |
|
---|
121 | <!-- ==================================================================== -->
|
---|
122 |
|
---|
123 | <xsl:template match="footnote/para[1]|footnote/simpara[1]" priority="2">
|
---|
124 | <!-- this only works if the first thing in a footnote is a para, -->
|
---|
125 | <!-- which is ok, because it usually is. -->
|
---|
126 | <xsl:variable name="href">
|
---|
127 | <xsl:text>#</xsl:text>
|
---|
128 | <xsl:call-template name="object.id">
|
---|
129 | <xsl:with-param name="object" select="ancestor::footnote"/>
|
---|
130 | </xsl:call-template>
|
---|
131 | </xsl:variable>
|
---|
132 |
|
---|
133 | <xsl:call-template name="paragraph">
|
---|
134 | <xsl:with-param name="class">
|
---|
135 | <xsl:if test="@role and $para.propagates.style != 0">
|
---|
136 | <xsl:value-of select="@role"/>
|
---|
137 | </xsl:if>
|
---|
138 | </xsl:with-param>
|
---|
139 | <xsl:with-param name="content">
|
---|
140 | <a href="{$href}">
|
---|
141 | <xsl:apply-templates select="." mode="class.attribute"/>
|
---|
142 | <sup>
|
---|
143 | <xsl:apply-templates select="." mode="class.attribute"/>
|
---|
144 | <xsl:text>[</xsl:text>
|
---|
145 | <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
|
---|
146 | <xsl:text>] </xsl:text>
|
---|
147 | </sup>
|
---|
148 | </a>
|
---|
149 | <xsl:apply-templates/>
|
---|
150 | </xsl:with-param>
|
---|
151 | </xsl:call-template>
|
---|
152 |
|
---|
153 | </xsl:template>
|
---|
154 |
|
---|
155 | <!-- ==================================================================== -->
|
---|
156 |
|
---|
157 | <xsl:template match="*" mode="footnote.body.number">
|
---|
158 | <xsl:variable name="name">
|
---|
159 | <xsl:text>ftn.</xsl:text>
|
---|
160 | <xsl:call-template name="object.id">
|
---|
161 | <xsl:with-param name="object" select="ancestor::footnote"/>
|
---|
162 | </xsl:call-template>
|
---|
163 | </xsl:variable>
|
---|
164 | <xsl:variable name="href">
|
---|
165 | <xsl:text>#</xsl:text>
|
---|
166 | <xsl:call-template name="object.id">
|
---|
167 | <xsl:with-param name="object" select="ancestor::footnote"/>
|
---|
168 | </xsl:call-template>
|
---|
169 | </xsl:variable>
|
---|
170 | <xsl:variable name="footnote.mark">
|
---|
171 | <a href="{$href}">
|
---|
172 | <xsl:apply-templates select="." mode="class.attribute"/>
|
---|
173 | <xsl:choose>
|
---|
174 | <xsl:when test="$generate.id.attributes = 0">
|
---|
175 | <xsl:if test="@id or @xml:id">
|
---|
176 | <xsl:attribute name="id">
|
---|
177 | <xsl:value-of select="@id|@xml:id"/>
|
---|
178 | </xsl:attribute>
|
---|
179 | </xsl:if>
|
---|
180 | </xsl:when>
|
---|
181 | <xsl:otherwise>
|
---|
182 | <xsl:call-template name="id.attribute"/>
|
---|
183 | </xsl:otherwise>
|
---|
184 | </xsl:choose>
|
---|
185 | <sup>
|
---|
186 | <xsl:text>[</xsl:text>
|
---|
187 | <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
|
---|
188 | <xsl:text>] </xsl:text>
|
---|
189 | </sup>
|
---|
190 | </a>
|
---|
191 | </xsl:variable>
|
---|
192 |
|
---|
193 | <xsl:variable name="html">
|
---|
194 | <xsl:apply-templates select="."/>
|
---|
195 | </xsl:variable>
|
---|
196 |
|
---|
197 | <xsl:choose>
|
---|
198 | <xsl:when test="$exsl.node.set.available != 0">
|
---|
199 | <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
|
---|
200 | <xsl:choose>
|
---|
201 | <xsl:when test="$html-nodes//p">
|
---|
202 | <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
|
---|
203 | <xsl:with-param name="mark" select="$footnote.mark"/>
|
---|
204 | </xsl:apply-templates>
|
---|
205 | </xsl:when>
|
---|
206 | <xsl:otherwise>
|
---|
207 | <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
|
---|
208 | <xsl:with-param name="mark" select="$footnote.mark"/>
|
---|
209 | </xsl:apply-templates>
|
---|
210 | </xsl:otherwise>
|
---|
211 | </xsl:choose>
|
---|
212 | </xsl:when>
|
---|
213 | <xsl:otherwise>
|
---|
214 | <xsl:copy-of select="$html"/>
|
---|
215 | </xsl:otherwise>
|
---|
216 | </xsl:choose>
|
---|
217 | </xsl:template>
|
---|
218 |
|
---|
219 | <!-- ==================================================================== -->
|
---|
220 |
|
---|
221 | <!--
|
---|
222 | <xsl:template name="count-element-from">
|
---|
223 | <xsl:param name="from" select=".."/>
|
---|
224 | <xsl:param name="to" select="."/>
|
---|
225 | <xsl:param name="count" select="0"/>
|
---|
226 | <xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
|
---|
227 | |$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
|
---|
228 |
|
---|
229 | <xsl:choose>
|
---|
230 | <xsl:when test="not($list)">
|
---|
231 | <xsl:text>-1</xsl:text>
|
---|
232 | </xsl:when>
|
---|
233 | <xsl:when test="$list[1] = $to">
|
---|
234 | <xsl:value-of select="$count + 1"/>
|
---|
235 | </xsl:when>
|
---|
236 | <xsl:otherwise>
|
---|
237 | </xsl:otherwise>
|
---|
238 | </xsl:choose>
|
---|
239 | </xsl:template>
|
---|
240 | -->
|
---|
241 |
|
---|
242 | <!-- ==================================================================== -->
|
---|
243 |
|
---|
244 | <xsl:template name="process.footnotes">
|
---|
245 | <xsl:variable name="footnotes" select=".//footnote"/>
|
---|
246 | <xsl:variable name="table.footnotes" select=".//table//footnote | .//informaltable//footnote"/>
|
---|
247 |
|
---|
248 | <!-- Only bother to do this if there's at least one non-table footnote -->
|
---|
249 | <xsl:if test="count($footnotes)>count($table.footnotes)">
|
---|
250 | <div class="footnotes">
|
---|
251 | <xsl:call-template name="footnotes.attributes"/>
|
---|
252 | <br/>
|
---|
253 | <hr/>
|
---|
254 | <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
|
---|
255 | </div>
|
---|
256 | </xsl:if>
|
---|
257 |
|
---|
258 | <xsl:if test="$annotation.support != 0 and //annotation">
|
---|
259 | <div class="annotation-list">
|
---|
260 | <div class="annotation-nocss">
|
---|
261 | <p>The following annotations are from this essay. You are seeing
|
---|
262 | them here because your browser doesn’t support the user-interface
|
---|
263 | techniques used to make them appear as ‘popups’ on modern browsers.</p>
|
---|
264 | </div>
|
---|
265 |
|
---|
266 | <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
|
---|
267 | </div>
|
---|
268 | </xsl:if>
|
---|
269 | </xsl:template>
|
---|
270 |
|
---|
271 | <xsl:template name="footnotes.attributes">
|
---|
272 | <!-- customizable for footnotes attributes -->
|
---|
273 | </xsl:template>
|
---|
274 |
|
---|
275 | <xsl:template name="process.chunk.footnotes">
|
---|
276 | <!-- nop -->
|
---|
277 | </xsl:template>
|
---|
278 |
|
---|
279 | <xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">
|
---|
280 | <xsl:variable name="id">
|
---|
281 | <xsl:text>ftn.</xsl:text>
|
---|
282 | <xsl:call-template name="object.id">
|
---|
283 | <xsl:with-param name="conditional" select="0"/>
|
---|
284 | </xsl:call-template>
|
---|
285 | </xsl:variable>
|
---|
286 |
|
---|
287 | <xsl:choose>
|
---|
288 | <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
|
---|
289 | <div id="{$id}">
|
---|
290 | <xsl:call-template name="common.html.attributes"/>
|
---|
291 | <xsl:apply-templates/>
|
---|
292 | </div>
|
---|
293 | </xsl:when>
|
---|
294 |
|
---|
295 | <xsl:when test="$html.cleanup != 0 and $exsl.node.set.available != 0">
|
---|
296 | <div id="{$id}">
|
---|
297 | <xsl:call-template name="common.html.attributes"/>
|
---|
298 | <xsl:call-template name="id.attribute"/>
|
---|
299 | <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
|
---|
300 | <xsl:apply-templates select="*[position() > 1]"/>
|
---|
301 | </div>
|
---|
302 | </xsl:when>
|
---|
303 |
|
---|
304 | <xsl:otherwise>
|
---|
305 | <xsl:message>
|
---|
306 | <xsl:text>Warning: footnote number may not be generated </xsl:text>
|
---|
307 | <xsl:text>correctly; </xsl:text>
|
---|
308 | <xsl:value-of select="local-name(*[1])"/>
|
---|
309 | <xsl:text> unexpected as first child of footnote.</xsl:text>
|
---|
310 | </xsl:message>
|
---|
311 | <div id="{$id}">
|
---|
312 | <xsl:call-template name="common.html.attributes"/>
|
---|
313 | <xsl:call-template name="id.attribute"/>
|
---|
314 | <xsl:apply-templates/>
|
---|
315 | </div>
|
---|
316 | </xsl:otherwise>
|
---|
317 | </xsl:choose>
|
---|
318 | </xsl:template>
|
---|
319 |
|
---|
320 | <xsl:template match="table//footnote | informaltable//footnote" mode="process.footnote.mode">
|
---|
321 | </xsl:template>
|
---|
322 |
|
---|
323 | <xsl:template match="footnote" mode="table.footnote.mode">
|
---|
324 | <xsl:call-template name="process.footnote"/>
|
---|
325 | </xsl:template>
|
---|
326 |
|
---|
327 | </xsl:stylesheet> |
---|