1<?xml version='1.0'?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 version='1.0'> 4 5<!-- ******************************************************************** 6 $Id$ 7 ******************************************************************** 8 9 This file is part of the XSL DocBook Stylesheet distribution. 10 See /README or http://nwalsh.com/docbook/xsl/ for copyright 11 and other information. 12 13 ******************************************************************** --> 14 15<xsl:template match="footnote"> 16 <xsl:variable name="name"> 17 <xsl:call-template name="object.id"/> 18 </xsl:variable> 19 <xsl:variable name="href"> 20 <xsl:text>#ftn.</xsl:text> 21 <xsl:call-template name="object.id"/> 22 </xsl:variable> 23 24 <xsl:choose> 25 <xsl:when test="ancestor::table|ancestor::informaltable"> 26 <sup> 27 <xsl:text>[</xsl:text> 28 <a name="{$name}" href="{$href}"> 29 <xsl:apply-templates select="." mode="footnote.number"/> 30 </a> 31 <xsl:text>]</xsl:text> 32 </sup> 33 </xsl:when> 34 <xsl:otherwise> 35 <sup> 36 <xsl:text>[</xsl:text> 37 <a name="{$name}" href="{$href}"> 38 <xsl:apply-templates select="." mode="footnote.number"/> 39 </a> 40 <xsl:text>]</xsl:text> 41 </sup> 42 </xsl:otherwise> 43 </xsl:choose> 44</xsl:template> 45 46<xsl:template match="footnoteref"> 47 <xsl:variable name="targets" select="id(@linkend)"/> 48 <xsl:variable name="footnote" select="$targets[1]"/> 49 <xsl:variable name="href"> 50 <xsl:text>#ftn.</xsl:text> 51 <xsl:call-template name="object.id"> 52 <xsl:with-param name="object" select="$footnote"/> 53 </xsl:call-template> 54 </xsl:variable> 55 <sup> 56 <xsl:text>[</xsl:text> 57 <a href="{$href}"> 58 <xsl:apply-templates select="$footnote" mode="footnote.number"/> 59 </a> 60 <xsl:text>]</xsl:text> 61 </sup> 62</xsl:template> 63 64<xsl:template match="footnote" mode="footnote.number"> 65 <xsl:choose> 66 <xsl:when test="ancestor::table|ancestor::informaltable"> 67 <xsl:number level="any" from="table|informaltable" format="a"/> 68 </xsl:when> 69 <xsl:otherwise> 70 <xsl:number level="any" format="1"/> 71 </xsl:otherwise> 72 </xsl:choose> 73</xsl:template> 74 75<!-- ==================================================================== --> 76 77<xsl:template match="footnote/para[1]"> 78 <!-- this only works if the first thing in a footnote is a para, --> 79 <!-- which is ok, because it usually is. --> 80 <xsl:variable name="name"> 81 <xsl:text>ftn.</xsl:text> 82 <xsl:call-template name="object.id"> 83 <xsl:with-param name="object" select="ancestor::footnote"/> 84 </xsl:call-template> 85 </xsl:variable> 86 <xsl:variable name="href"> 87 <xsl:text>#</xsl:text> 88 <xsl:call-template name="object.id"> 89 <xsl:with-param name="object" select="ancestor::footnote"/> 90 </xsl:call-template> 91 </xsl:variable> 92 <p> 93 <sup> 94 <xsl:text>[</xsl:text> 95 <a name="{$name}" href="{$href}"> 96 <xsl:apply-templates select="ancestor::footnote" 97 mode="footnote.number"/> 98 </a> 99 <xsl:text>] </xsl:text> 100 </sup> 101 <xsl:apply-templates/> 102 </p> 103</xsl:template> 104 105<!-- ==================================================================== --> 106 107<xsl:template name="process.footnotes"> 108 <xsl:variable name="footnotes" select=".//footnote"/> 109 <xsl:variable name="table.footnotes" 110 select=".//table//footnote|.//informaltable//footnote"/> 111 112 <!-- Only bother to do this if there's at least one non-table footnote --> 113 <xsl:if test="count($footnotes)>count($table.footnotes)"> 114 <div class="footnotes"> 115 <br/> 116 <hr width="100" align="left"/> 117 <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/> 118 </div> 119 </xsl:if> 120</xsl:template> 121 122<xsl:template name="process.chunk.footnotes"> 123 <!-- nop --> 124</xsl:template> 125 126<xsl:template match="footnote" mode="process.footnote.mode"> 127 <div class="{name(.)}"> 128 <xsl:apply-templates/> 129 </div> 130</xsl:template> 131 132<xsl:template match="informaltable//footnote|table//footnote" 133 mode="process.footnote.mode"> 134</xsl:template> 135 136<xsl:template match="footnote" mode="table.footnote.mode"> 137 <div class="{name(.)}"> 138 <xsl:apply-templates/> 139 </div> 140</xsl:template> 141 142</xsl:stylesheet> 143