]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/xhtml/footnote.xsl
Add stylesheets for our evergreen docbook site.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / xhtml / footnote.xsl
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">
5
6 <!-- ********************************************************************
7      $Id: footnote.xsl 8421 2009-05-04 07:49:49Z bobstayton $
8      ********************************************************************
9
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.
13
14      ******************************************************************** -->
15
16 <xsl:template match="footnote">
17   <xsl:variable name="name">
18     <xsl:call-template name="object.id"/>
19   </xsl:variable>
20   <xsl:variable name="href">
21     <xsl:text>#ftn.</xsl:text>
22     <xsl:call-template name="object.id"/>
23   </xsl:variable>
24
25   <xsl:choose>
26     <xsl:when test="ancestor::tgroup">
27       <sup>
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"/>
32         </a>
33         <xsl:text>]</xsl:text>
34       </sup>
35     </xsl:when>
36     <xsl:otherwise>
37       <sup>
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"/>
42         </a>
43         <xsl:text>]</xsl:text>
44       </sup>
45     </xsl:otherwise>
46   </xsl:choose>
47 </xsl:template>
48
49 <xsl:template match="footnoteref">
50   <xsl:variable name="targets" select="key('id',@linkend)"/>
51   <xsl:variable name="footnote" select="$targets[1]"/>
52
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"/>
59    </xsl:message>
60   </xsl:if>
61
62   <xsl:variable name="target.href">
63     <xsl:call-template name="href.target">
64       <xsl:with-param name="object" select="$footnote"/>
65     </xsl:call-template>
66   </xsl:variable>
67
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, '#')"/>
72   </xsl:variable>
73
74   <sup>
75     <xsl:text>[</xsl:text>
76     <a href="{$href}">
77       <xsl:apply-templates select="." mode="class.attribute"/>
78       <xsl:apply-templates select="$footnote" mode="footnote.number"/>
79     </a>
80     <xsl:text>]</xsl:text>
81   </sup>
82 </xsl:template>
83
84 <xsl:template match="footnote" mode="footnote.number">
85   <xsl:choose>
86     <xsl:when test="string-length(@label) != 0">
87       <xsl:value-of select="@label"/>
88     </xsl:when>
89     <xsl:when test="ancestor::tgroup">
90       <xsl:variable name="tfnum">
91         <xsl:number level="any" from="table|informaltable" format="1"/>
92       </xsl:variable>
93
94       <xsl:choose>
95         <xsl:when test="string-length($table.footnote.number.symbols) &gt;= $tfnum">
96           <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
97         </xsl:when>
98         <xsl:otherwise>
99           <xsl:number level="any" from="tgroup" format="{$table.footnote.number.format}"/>
100         </xsl:otherwise>
101       </xsl:choose>
102     </xsl:when>
103     <xsl:otherwise>
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"/>
107
108       <xsl:choose>
109         <xsl:when test="string-length($footnote.number.symbols) &gt;= $fnum">
110           <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
111         </xsl:when>
112         <xsl:otherwise>
113           <xsl:number value="$fnum" format="{$footnote.number.format}"/>
114         </xsl:otherwise>
115       </xsl:choose>
116     </xsl:otherwise>
117   </xsl:choose>
118 </xsl:template>
119
120 <!-- ==================================================================== -->
121
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"/>
129     </xsl:call-template>
130   </xsl:variable>
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"/>
135     </xsl:call-template>
136   </xsl:variable>
137   <p>
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>
143     </xsl:if>
144     <sup>
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"/>
149       </a>
150       <xsl:text>] </xsl:text>
151     </sup>
152     <xsl:apply-templates/>
153   </p>
154 </xsl:template>
155
156 <!-- ==================================================================== -->
157
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"/>
163     </xsl:call-template>
164   </xsl:variable>
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"/>
169     </xsl:call-template>
170   </xsl:variable>
171   <xsl:variable name="footnote.mark">
172     <sup>
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"/>
177       </a>
178       <xsl:text>] </xsl:text>
179     </sup>
180   </xsl:variable>
181
182   <xsl:variable name="html">
183     <xsl:apply-templates select="."/>
184   </xsl:variable>
185
186   <xsl:choose>
187     <xsl:when test="$exsl.node.set.available != 0">
188       <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
189       <xsl:choose>
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>
194         </xsl:when>
195         <xsl:otherwise>
196           <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
197             <xsl:with-param name="mark" select="$footnote.mark"/>
198           </xsl:apply-templates>
199         </xsl:otherwise>
200       </xsl:choose>
201     </xsl:when>
202     <xsl:otherwise>
203       <xsl:copy-of select="$html"/>
204     </xsl:otherwise>
205   </xsl:choose>
206 </xsl:template>
207
208 <!-- ==================================================================== -->
209
210 <!--
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)]"/>
217
218   <xsl:choose>
219     <xsl:when test="not($list)">
220       <xsl:text>-1</xsl:text>
221     </xsl:when>
222     <xsl:when test="$list[1] = $to">
223       <xsl:value-of select="$count + 1"/>
224     </xsl:when>
225     <xsl:otherwise>
226     </xsl:otherwise>
227   </xsl:choose>
228 </xsl:template>
229 -->
230
231 <!-- ==================================================================== -->
232
233 <xsl:template name="process.footnotes">
234   <xsl:variable name="footnotes" select=".//footnote"/>
235   <xsl:variable name="table.footnotes" select=".//tgroup//footnote"/>
236
237   <!-- Only bother to do this if there's at least one non-table footnote -->
238   <xsl:if test="count($footnotes)&gt;count($table.footnotes)">
239     <div class="footnotes">
240       <br/>
241       <hr width="100" align="{$direction.align.start}"/>
242       <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
243     </div>
244   </xsl:if>
245
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&#8217;t support the user-interface
251         techniques used to make them appear as &#8216;popups&#8217; on modern browsers.</p>
252       </div>
253
254       <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
255     </div>
256   </xsl:if>
257 </xsl:template>
258
259 <xsl:template name="process.chunk.footnotes">
260   <!-- nop -->
261 </xsl:template>
262
263 <xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">
264   <xsl:choose>
265     <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
266       <div>
267         <xsl:call-template name="common.html.attributes"/>
268         <xsl:apply-templates/>
269       </div>
270     </xsl:when>
271
272     <xsl:when test="$html.cleanup != 0 and                      $exsl.node.set.available != 0">
273       <div>
274         <xsl:call-template name="common.html.attributes"/>
275         <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
276         <xsl:apply-templates select="*[position() &gt; 1]"/>
277       </div>
278     </xsl:when>
279
280     <xsl:otherwise>
281       <xsl:message>
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>
286       </xsl:message>
287       <div>
288         <xsl:call-template name="common.html.attributes"/>
289         <xsl:apply-templates/>
290       </div>
291     </xsl:otherwise>
292   </xsl:choose>
293 </xsl:template>
294
295 <xsl:template match="tgroup//footnote" mode="process.footnote.mode">
296 </xsl:template>
297
298 <xsl:template match="footnote" mode="table.footnote.mode">
299   <xsl:call-template name="process.footnote"/>
300 </xsl:template>
301
302 </xsl:stylesheet>