[c873d807] | 1 | <?xml version='1.0'?>
|
---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 3 | xmlns:fo="http://www.w3.org/1999/XSL/Format"
|
---|
[15c7d39] | 4 | xmlns:xlink="http://www.w3.org/1999/xlink"
|
---|
[c873d807] | 5 | xmlns:exsl="http://exslt.org/common"
|
---|
[15c7d39] | 6 | exclude-result-prefixes="exsl xlink"
|
---|
[c873d807] | 7 | version='1.0'>
|
---|
| 8 |
|
---|
| 9 | <!-- ********************************************************************
|
---|
[15c7d39] | 10 | $Id: footnote.xsl 8359 2009-03-20 18:42:06Z bobstayton $
|
---|
[c873d807] | 11 | ********************************************************************
|
---|
| 12 |
|
---|
| 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.
|
---|
| 16 |
|
---|
| 17 | ******************************************************************** -->
|
---|
| 18 |
|
---|
| 19 | <xsl:template name="format.footnote.mark">
|
---|
| 20 | <xsl:param name="mark" select="'?'"/>
|
---|
| 21 | <fo:inline xsl:use-attribute-sets="footnote.mark.properties">
|
---|
| 22 | <xsl:choose>
|
---|
| 23 | <xsl:when test="$fop.extensions != 0">
|
---|
| 24 | <xsl:attribute name="vertical-align">super</xsl:attribute>
|
---|
| 25 | </xsl:when>
|
---|
| 26 | <xsl:otherwise>
|
---|
| 27 | <xsl:attribute name="baseline-shift">super</xsl:attribute>
|
---|
| 28 | </xsl:otherwise>
|
---|
| 29 | </xsl:choose>
|
---|
| 30 | <xsl:copy-of select="$mark"/>
|
---|
| 31 | </fo:inline>
|
---|
| 32 | </xsl:template>
|
---|
| 33 |
|
---|
| 34 | <xsl:template match="footnote">
|
---|
| 35 | <xsl:choose>
|
---|
| 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"/>
|
---|
| 40 | </xsl:with-param>
|
---|
| 41 | </xsl:call-template>
|
---|
| 42 | </xsl:when>
|
---|
| 43 | <xsl:otherwise>
|
---|
| 44 | <fo:footnote>
|
---|
| 45 | <fo:inline>
|
---|
| 46 | <xsl:call-template name="format.footnote.mark">
|
---|
| 47 | <xsl:with-param name="mark">
|
---|
| 48 | <xsl:apply-templates select="." mode="footnote.number"/>
|
---|
| 49 | </xsl:with-param>
|
---|
| 50 | </xsl:call-template>
|
---|
| 51 | </fo:inline>
|
---|
| 52 | <fo:footnote-body xsl:use-attribute-sets="footnote.properties">
|
---|
| 53 | <xsl:apply-templates/>
|
---|
| 54 | </fo:footnote-body>
|
---|
| 55 | </fo:footnote>
|
---|
| 56 | </xsl:otherwise>
|
---|
| 57 | </xsl:choose>
|
---|
| 58 | </xsl:template>
|
---|
| 59 |
|
---|
| 60 | <xsl:template match="footnoteref">
|
---|
| 61 | <xsl:variable name="footnote" select="key('id',@linkend)"/>
|
---|
[15c7d39] | 62 |
|
---|
| 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"/>
|
---|
| 69 | </xsl:message>
|
---|
| 70 | </xsl:if>
|
---|
| 71 |
|
---|
[c873d807] | 72 | <xsl:call-template name="format.footnote.mark">
|
---|
| 73 | <xsl:with-param name="mark">
|
---|
| 74 | <xsl:apply-templates select="$footnote" mode="footnote.number"/>
|
---|
| 75 | </xsl:with-param>
|
---|
| 76 | </xsl:call-template>
|
---|
| 77 | </xsl:template>
|
---|
| 78 |
|
---|
| 79 | <xsl:template match="footnote" mode="footnote.number">
|
---|
| 80 | <xsl:choose>
|
---|
| 81 | <xsl:when test="string-length(@label) != 0">
|
---|
| 82 | <xsl:value-of select="@label"/>
|
---|
| 83 | </xsl:when>
|
---|
| 84 | <xsl:when test="ancestor::table or ancestor::informaltable">
|
---|
| 85 | <xsl:variable name="tfnum">
|
---|
| 86 | <xsl:number level="any" from="table|informaltable" format="1"/>
|
---|
| 87 | </xsl:variable>
|
---|
| 88 |
|
---|
| 89 | <xsl:choose>
|
---|
| 90 | <xsl:when test="string-length($table.footnote.number.symbols) >= $tfnum">
|
---|
| 91 | <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
|
---|
| 92 | </xsl:when>
|
---|
| 93 | <xsl:otherwise>
|
---|
| 94 | <xsl:number level="any" from="table|informaltable"
|
---|
| 95 | format="{$table.footnote.number.format}"/>
|
---|
| 96 | </xsl:otherwise>
|
---|
| 97 | </xsl:choose>
|
---|
| 98 | </xsl:when>
|
---|
| 99 | <xsl:otherwise>
|
---|
| 100 | <xsl:variable name="fnum">
|
---|
[15c7d39] | 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: -->
|
---|
| 104 | <!-- * -->
|
---|
| 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' -->
|
---|
| 114 | <!-- * -->
|
---|
| 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 -->
|
---|
| 117 | <!-- * non-zero -->
|
---|
[c873d807] | 118 | <!-- FIXME: list in @from is probably not complete -->
|
---|
| 119 | <xsl:number level="any"
|
---|
| 120 | from="chapter|appendix|preface|article|refentry|bibliography"
|
---|
[15c7d39] | 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]
|
---|
| 127 | "
|
---|
[c873d807] | 128 | format="1"/>
|
---|
| 129 | </xsl:variable>
|
---|
| 130 | <xsl:choose>
|
---|
| 131 | <xsl:when test="string-length($footnote.number.symbols) >= $fnum">
|
---|
| 132 | <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
|
---|
| 133 | </xsl:when>
|
---|
| 134 | <xsl:otherwise>
|
---|
| 135 | <xsl:number value="$fnum" format="{$footnote.number.format}"/>
|
---|
| 136 | </xsl:otherwise>
|
---|
| 137 | </xsl:choose>
|
---|
| 138 | </xsl:otherwise>
|
---|
| 139 | </xsl:choose>
|
---|
| 140 | </xsl:template>
|
---|
| 141 |
|
---|
| 142 | <!-- ==================================================================== -->
|
---|
| 143 |
|
---|
| 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"/>
|
---|
| 149 | </xsl:with-param>
|
---|
| 150 | </xsl:call-template>
|
---|
| 151 | </xsl:variable>
|
---|
| 152 |
|
---|
| 153 | <xsl:variable name="fo">
|
---|
| 154 | <xsl:apply-templates select="."/>
|
---|
| 155 | </xsl:variable>
|
---|
| 156 |
|
---|
| 157 | <xsl:variable name="fo-nodes" select="exsl:node-set($fo)"/>
|
---|
| 158 |
|
---|
| 159 | <xsl:choose>
|
---|
| 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>
|
---|
| 164 | </xsl:when>
|
---|
| 165 | <xsl:otherwise>
|
---|
| 166 | <xsl:apply-templates select="$fo-nodes" mode="insert.fo.text">
|
---|
| 167 | <xsl:with-param name="mark" select="$footnote.mark"/>
|
---|
| 168 | </xsl:apply-templates>
|
---|
| 169 | </xsl:otherwise>
|
---|
| 170 | </xsl:choose>
|
---|
| 171 | </xsl:template>
|
---|
| 172 |
|
---|
| 173 | <!-- ==================================================================== -->
|
---|
| 174 |
|
---|
| 175 | <xsl:template match="footnote/para[1]
|
---|
| 176 | |footnote/simpara[1]
|
---|
| 177 | |footnote/formalpara[1]"
|
---|
| 178 | priority="2">
|
---|
| 179 | <!-- this only works if the first thing in a footnote is a para, -->
|
---|
| 180 | <!-- which is ok, because it usually is. -->
|
---|
| 181 | <fo:block>
|
---|
| 182 | <xsl:call-template name="format.footnote.mark">
|
---|
| 183 | <xsl:with-param name="mark">
|
---|
| 184 | <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
|
---|
| 185 | </xsl:with-param>
|
---|
| 186 | </xsl:call-template>
|
---|
| 187 | <xsl:apply-templates/>
|
---|
| 188 | </fo:block>
|
---|
| 189 | </xsl:template>
|
---|
| 190 |
|
---|
| 191 | <xsl:template match="footnote" mode="table.footnote.mode">
|
---|
| 192 | <xsl:choose>
|
---|
| 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/>
|
---|
| 196 | </fo:block>
|
---|
| 197 | </xsl:when>
|
---|
| 198 |
|
---|
[15c7d39] | 199 | <xsl:when test="$exsl.node.set.available != 0">
|
---|
[c873d807] | 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]"/>
|
---|
| 203 | </fo:block>
|
---|
| 204 | </xsl:when>
|
---|
| 205 |
|
---|
| 206 | <xsl:otherwise>
|
---|
| 207 | <xsl:message>
|
---|
| 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>
|
---|
| 212 | </xsl:message>
|
---|
| 213 | <fo:block xsl:use-attribute-sets="table.footnote.properties">
|
---|
| 214 | <xsl:apply-templates/>
|
---|
| 215 | </fo:block>
|
---|
| 216 | </xsl:otherwise>
|
---|
| 217 | </xsl:choose>
|
---|
| 218 | </xsl:template>
|
---|
| 219 |
|
---|
| 220 | </xsl:stylesheet>
|
---|