~todd-deshane/openstack-manuals/working

« back to all changes in this revision

Viewing changes to doc/build/docbook-xsl-1.76.1/xhtml-1_1/footnote.xsl

  • Committer: Anne Gentle
  • Date: 2011-04-04 17:54:52 UTC
  • Revision ID: anne@openstack.org-20110404175452-gtth3hfrniqhpp5o
Switching from Ant builds to Maven, still working out kinks but should be functional

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 8812 2010-08-09 20:51:51Z 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::table or ancestor::informaltable">
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::table or ancestor::informaltable">
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="table | informaltable" 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::table//footnote |                                           preceding::informaltable//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
 
 
138
 
  <xsl:call-template name="paragraph">
139
 
    <xsl:with-param name="class">
140
 
      <xsl:if test="@role and $para.propagates.style != 0">
141
 
        <xsl:value-of select="@role"/>
142
 
      </xsl:if>
143
 
    </xsl:with-param>
144
 
    <xsl:with-param name="content">
145
 
      <sup>
146
 
        <xsl:text>[</xsl:text>
147
 
        <a id="{$name}" href="{$href}">
148
 
          <xsl:apply-templates select="." mode="class.attribute"/>
149
 
          <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
150
 
        </a>
151
 
        <xsl:text>] </xsl:text>
152
 
      </sup>
153
 
      <xsl:apply-templates/>
154
 
    </xsl:with-param>
155
 
  </xsl:call-template>
156
 
 
157
 
</xsl:template>
158
 
 
159
 
<!-- ==================================================================== -->
160
 
 
161
 
<xsl:template match="*" mode="footnote.body.number">
162
 
  <xsl:variable name="name">
163
 
    <xsl:text>ftn.</xsl:text>
164
 
    <xsl:call-template name="object.id">
165
 
      <xsl:with-param name="object" select="ancestor::footnote"/>
166
 
    </xsl:call-template>
167
 
  </xsl:variable>
168
 
  <xsl:variable name="href">
169
 
    <xsl:text>#</xsl:text>
170
 
    <xsl:call-template name="object.id">
171
 
      <xsl:with-param name="object" select="ancestor::footnote"/>
172
 
    </xsl:call-template>
173
 
  </xsl:variable>
174
 
  <xsl:variable name="footnote.mark">
175
 
    <sup>
176
 
      <xsl:text>[</xsl:text>
177
 
      <a id="{$name}" href="{$href}">
178
 
        <xsl:apply-templates select="." mode="class.attribute"/>
179
 
        <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
180
 
      </a>
181
 
      <xsl:text>] </xsl:text>
182
 
    </sup>
183
 
  </xsl:variable>
184
 
 
185
 
  <xsl:variable name="html">
186
 
    <xsl:apply-templates select="."/>
187
 
  </xsl:variable>
188
 
 
189
 
  <xsl:choose>
190
 
    <xsl:when test="$exsl.node.set.available != 0">
191
 
      <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
192
 
      <xsl:choose>
193
 
        <xsl:when test="$html-nodes//p">
194
 
          <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
195
 
            <xsl:with-param name="mark" select="$footnote.mark"/>
196
 
          </xsl:apply-templates>
197
 
        </xsl:when>
198
 
        <xsl:otherwise>
199
 
          <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
200
 
            <xsl:with-param name="mark" select="$footnote.mark"/>
201
 
          </xsl:apply-templates>
202
 
        </xsl:otherwise>
203
 
      </xsl:choose>
204
 
    </xsl:when>
205
 
    <xsl:otherwise>
206
 
      <xsl:copy-of select="$html"/>
207
 
    </xsl:otherwise>
208
 
  </xsl:choose>
209
 
</xsl:template>
210
 
 
211
 
<!-- ==================================================================== -->
212
 
 
213
 
<!--
214
 
<xsl:template name="count-element-from">
215
 
  <xsl:param name="from" select=".."/>
216
 
  <xsl:param name="to" select="."/>
217
 
  <xsl:param name="count" select="0"/>
218
 
  <xsl:param name="list" select="$from/following::*[local-name(.)=local-name($to)]
219
 
                                 |$from/descendant-or-self::*[local-name(.)=local-name($to)]"/>
220
 
 
221
 
  <xsl:choose>
222
 
    <xsl:when test="not($list)">
223
 
      <xsl:text>-1</xsl:text>
224
 
    </xsl:when>
225
 
    <xsl:when test="$list[1] = $to">
226
 
      <xsl:value-of select="$count + 1"/>
227
 
    </xsl:when>
228
 
    <xsl:otherwise>
229
 
    </xsl:otherwise>
230
 
  </xsl:choose>
231
 
</xsl:template>
232
 
-->
233
 
 
234
 
<!-- ==================================================================== -->
235
 
 
236
 
<xsl:template name="process.footnotes">
237
 
  <xsl:variable name="footnotes" select=".//footnote"/>
238
 
  <xsl:variable name="table.footnotes" select=".//table//footnote | .//informaltable//footnote"/>
239
 
 
240
 
  <!-- Only bother to do this if there's at least one non-table footnote -->
241
 
  <xsl:if test="count($footnotes)&gt;count($table.footnotes)">
242
 
    <div class="footnotes">
243
 
      <br/>
244
 
      <hr/>
245
 
      <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
246
 
    </div>
247
 
  </xsl:if>
248
 
 
249
 
  <xsl:if test="$annotation.support != 0 and //annotation">
250
 
    <div class="annotation-list">
251
 
      <div class="annotation-nocss">
252
 
        <p>The following annotations are from this essay. You are seeing
253
 
        them here because your browser doesn&#8217;t support the user-interface
254
 
        techniques used to make them appear as &#8216;popups&#8217; on modern browsers.</p>
255
 
      </div>
256
 
 
257
 
      <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
258
 
    </div>
259
 
  </xsl:if>
260
 
</xsl:template>
261
 
 
262
 
<xsl:template name="process.chunk.footnotes">
263
 
  <!-- nop -->
264
 
</xsl:template>
265
 
 
266
 
<xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">
267
 
  <xsl:choose>
268
 
    <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
269
 
      <div>
270
 
        <xsl:call-template name="common.html.attributes"/>
271
 
        <xsl:apply-templates/>
272
 
      </div>
273
 
    </xsl:when>
274
 
 
275
 
    <xsl:when test="$html.cleanup != 0 and                      $exsl.node.set.available != 0">
276
 
      <div>
277
 
        <xsl:call-template name="common.html.attributes"/>
278
 
        <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
279
 
        <xsl:apply-templates select="*[position() &gt; 1]"/>
280
 
      </div>
281
 
    </xsl:when>
282
 
 
283
 
    <xsl:otherwise>
284
 
      <xsl:message>
285
 
        <xsl:text>Warning: footnote number may not be generated </xsl:text>
286
 
        <xsl:text>correctly; </xsl:text>
287
 
        <xsl:value-of select="local-name(*[1])"/>
288
 
        <xsl:text> unexpected as first child of footnote.</xsl:text>
289
 
      </xsl:message>
290
 
      <div>
291
 
        <xsl:call-template name="common.html.attributes"/>
292
 
        <xsl:apply-templates/>
293
 
      </div>
294
 
    </xsl:otherwise>
295
 
  </xsl:choose>
296
 
</xsl:template>
297
 
 
298
 
<xsl:template match="table//footnote | informaltable//footnote" mode="process.footnote.mode">
299
 
</xsl:template>
300
 
 
301
 
<xsl:template match="footnote" mode="table.footnote.mode">
302
 
  <xsl:call-template name="process.footnote"/>
303
 
</xsl:template>
304
 
 
305
 
</xsl:stylesheet>