2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 xmlns:xlink="http://www.w3.org/1999/xlink"
5 xmlns:exsl="http://exslt.org/common"
6 exclude-result-prefixes="exsl xlink"
9 <!-- ********************************************************************
10 $Id: footnote.xsl 8359 2009-03-20 18:42:06Z bobstayton $
11 ********************************************************************
13 This file is part of the XSL DocBook Stylesheet distribution.
14 See ../README or http://docbook.sf.net/release/xsl/current/ for
15 copyright and other information.
17 ******************************************************************** -->
19 <xsl:template name="format.footnote.mark">
20 <xsl:param name="mark" select="'?'"/>
21 <fo:inline xsl:use-attribute-sets="footnote.mark.properties">
23 <xsl:when test="$fop.extensions != 0">
24 <xsl:attribute name="vertical-align">super</xsl:attribute>
27 <xsl:attribute name="baseline-shift">super</xsl:attribute>
30 <xsl:copy-of select="$mark"/>
34 <xsl:template match="footnote">
36 <xsl:when test="ancestor::table or ancestor::informaltable">
37 <xsl:call-template name="format.footnote.mark">
38 <xsl:with-param name="mark">
39 <xsl:apply-templates select="." mode="footnote.number"/>
46 <xsl:call-template name="format.footnote.mark">
47 <xsl:with-param name="mark">
48 <xsl:apply-templates select="." mode="footnote.number"/>
52 <fo:footnote-body xsl:use-attribute-sets="footnote.properties">
53 <xsl:apply-templates/>
60 <xsl:template match="footnoteref">
61 <xsl:variable name="footnote" select="key('id',@linkend)"/>
63 <xsl:if test="not(local-name($footnote) = 'footnote')">
64 <xsl:message terminate="yes">
65 ERROR: A footnoteref element has a linkend that points to an element that is not a footnote.
66 Typically this happens when an id attribute is accidentally applied to the child of a footnote element.
67 target element: <xsl:value-of select="local-name($footnote)"/>
68 linkend/id: <xsl:value-of select="@linkend"/>
72 <xsl:call-template name="format.footnote.mark">
73 <xsl:with-param name="mark">
74 <xsl:apply-templates select="$footnote" mode="footnote.number"/>
79 <xsl:template match="footnote" mode="footnote.number">
81 <xsl:when test="string-length(@label) != 0">
82 <xsl:value-of select="@label"/>
84 <xsl:when test="ancestor::table or ancestor::informaltable">
85 <xsl:variable name="tfnum">
86 <xsl:number level="any" from="table|informaltable" format="1"/>
90 <xsl:when test="string-length($table.footnote.number.symbols) >= $tfnum">
91 <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
94 <xsl:number level="any" from="table|informaltable"
95 format="{$table.footnote.number.format}"/>
100 <xsl:variable name="fnum">
101 <!-- * Determine the footnote number to display for this footnote, -->
102 <!-- * by counting all foonotes, ulinks, and any elements that have -->
103 <!-- * an xlink:href attribute that meets the following criteria: -->
105 <!-- * - the content of the element is not a URI that is the same -->
106 <!-- * URI as the value of the href attribute -->
107 <!-- * - the href attribute is not an internal ID reference (does -->
108 <!-- * not start with a hash sign) -->
109 <!-- * - the href is not part of an olink reference (the element -->
110 <!-- * - does not have an xlink:role attribute that indicates it is -->
111 <!-- * an olink, and the hrf does not contain a hash sign) -->
112 <!-- * - the element either has no xlink:type attribute or has -->
113 <!-- * an xlink:type attribute whose value is 'simple' -->
115 <!-- * Note that hyperlinks are counted only if both the value of -->
116 <!-- * ulink.footnotes is non-zero and the value of ulink.show is -->
118 <!-- FIXME: list in @from is probably not complete -->
119 <xsl:number level="any"
120 from="chapter|appendix|preface|article|refentry|bibliography"
121 count="footnote[not(@label)][not(ancestor::table) and not(ancestor::informaltable)]
122 |ulink[$ulink.footnotes != 0][node()][@url != .][not(ancestor::footnote)][$ulink.show != 0]
123 |*[node()][@xlink:href][not(@xlink:href = .)][not(starts-with(@xlink:href,'#'))]
124 [not(contains(@xlink:href,'#') and @xlink:role = $xolink.role)]
125 [not(@xlink:type) or @xlink:type='simple']
126 [not(ancestor::footnote)][$ulink.footnotes != 0][$ulink.show != 0]
131 <xsl:when test="string-length($footnote.number.symbols) >= $fnum">
132 <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
135 <xsl:number value="$fnum" format="{$footnote.number.format}"/>
142 <!-- ==================================================================== -->
144 <xsl:template match="*" mode="footnote.body.number">
145 <xsl:variable name="footnote.mark">
146 <xsl:call-template name="format.footnote.mark">
147 <xsl:with-param name="mark">
148 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
153 <xsl:variable name="fo">
154 <xsl:apply-templates select="."/>
157 <xsl:variable name="fo-nodes" select="exsl:node-set($fo)"/>
160 <xsl:when test="$fo-nodes//fo:block">
161 <xsl:apply-templates select="$fo-nodes" mode="insert.fo.fnum">
162 <xsl:with-param name="mark" select="$footnote.mark"/>
163 </xsl:apply-templates>
166 <xsl:apply-templates select="$fo-nodes" mode="insert.fo.text">
167 <xsl:with-param name="mark" select="$footnote.mark"/>
168 </xsl:apply-templates>
173 <!-- ==================================================================== -->
175 <xsl:template match="footnote/para[1]
177 |footnote/formalpara[1]"
179 <!-- this only works if the first thing in a footnote is a para, -->
180 <!-- which is ok, because it usually is. -->
182 <xsl:call-template name="format.footnote.mark">
183 <xsl:with-param name="mark">
184 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
187 <xsl:apply-templates/>
191 <xsl:template match="footnote" mode="table.footnote.mode">
193 <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
194 <fo:block xsl:use-attribute-sets="table.footnote.properties">
195 <xsl:apply-templates/>
199 <xsl:when test="$exsl.node.set.available != 0">
200 <fo:block xsl:use-attribute-sets="table.footnote.properties">
201 <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
202 <xsl:apply-templates select="*[position() > 1]"/>
208 <xsl:text>Warning: footnote number may not be generated </xsl:text>
209 <xsl:text>correctly; </xsl:text>
210 <xsl:value-of select="local-name(*[1])"/>
211 <xsl:text> unexpected as first child of footnote.</xsl:text>
213 <fo:block xsl:use-attribute-sets="table.footnote.properties">
214 <xsl:apply-templates/>