| 1 |
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- --> |
| 2 |
<!-- |
| 3 |
This program is free software; you can redistribute it and/or modify it under |
| 4 |
the terms of the GNU Lesser General Public License as published by the Free |
| 5 |
Software Foundation; either version 2 of the License, or (at your option) any |
| 6 |
later version. |
| 7 |
|
| 8 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 10 |
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 11 |
details. |
| 12 |
|
| 13 |
You should have received a copy of the GNU Lesser General Public License |
| 14 |
along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
--> |
| 16 |
|
| 17 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 18 |
xmlns:db="http://docbook.org/ns/docbook" |
| 19 |
xmlns="http://www.w3.org/1999/xhtml" |
| 20 |
exclude-result-prefixes="db" |
| 21 |
version="1.0"> |
| 22 |
|
| 23 |
<!--!!========================================================================== |
| 24 |
DocBook to HTML - Footnotes |
| 25 |
|
| 26 |
FIXME: Describe this module |
| 27 |
--> |
| 28 |
|
| 29 |
|
| 30 |
<!--**========================================================================== |
| 31 |
db2html.footnote.link |
| 32 |
Output a link to a footnote. |
| 33 |
@revision[version=3.4 date=2011-11-10 status=final] |
| 34 |
|
| 35 |
[xsl:params] |
| 36 |
$node: The `footnote` element to process. |
| 37 |
|
| 38 |
This templates outputs an inline link to the footnote displayed at the bottom |
| 39 |
of the page. |
| 40 |
--> |
| 41 |
<xsl:template match="footnote | db:footnote" name="db2html.footnote.link"> |
| 42 |
<xsl:param name="node" select="."/> |
| 43 |
<xsl:variable name="anchor"> |
| 44 |
<xsl:text>-noteref-</xsl:text> |
| 45 |
<xsl:choose> |
| 46 |
<xsl:when test="$node/@id"> |
| 47 |
<xsl:value-of select="$node/@id"/> |
| 48 |
</xsl:when> |
| 49 |
<xsl:when test="$node/@xml:id"> |
| 50 |
<xsl:value-of select="$node/@xml:id"/> |
| 51 |
</xsl:when> |
| 52 |
<xsl:otherwise> |
| 53 |
<xsl:value-of select="generate-id($node)"/> |
| 54 |
</xsl:otherwise> |
| 55 |
</xsl:choose> |
| 56 |
</xsl:variable> |
| 57 |
<xsl:variable name="href"> |
| 58 |
<xsl:text>#</xsl:text> |
| 59 |
<xsl:choose> |
| 60 |
<xsl:when test="$node/@id"> |
| 61 |
<xsl:value-of select="$node/@id"/> |
| 62 |
</xsl:when> |
| 63 |
<xsl:when test="$node/@xml:id"> |
| 64 |
<xsl:value-of select="$node/@xml:id"/> |
| 65 |
</xsl:when> |
| 66 |
<xsl:otherwise> |
| 67 |
<xsl:text>-note-</xsl:text> |
| 68 |
<xsl:value-of select="generate-id($node)"/> |
| 69 |
</xsl:otherwise> |
| 70 |
</xsl:choose> |
| 71 |
</xsl:variable> |
| 72 |
<sup class="footnote"> |
| 73 |
<a class="footnote" href="{$href}" id="{$anchor}"> |
| 74 |
<xsl:value-of select="count($node/preceding::footnote | $node/preceding::db:footnote) + 1"/> |
| 75 |
</a> |
| 76 |
</sup> |
| 77 |
</xsl:template> |
| 78 |
|
| 79 |
|
| 80 |
<!--**========================================================================== |
| 81 |
db2html.footnote.note |
| 82 |
Output a footnote. |
| 83 |
@revision[version=3.4 date=2011-11-10 status=final] |
| 84 |
|
| 85 |
[xsl:params] |
| 86 |
$node: The `footnote` element to process. |
| 87 |
|
| 88 |
This templates outputs the actual text of a footnote as a block-level element. |
| 89 |
--> |
| 90 |
<xsl:template name="db2html.footnote.note"> |
| 91 |
<xsl:param name="node" select="."/> |
| 92 |
<xsl:variable name="anchor"> |
| 93 |
<xsl:choose> |
| 94 |
<xsl:when test="$node/@id"> |
| 95 |
<xsl:value-of select="$node/@id"/> |
| 96 |
</xsl:when> |
| 97 |
<xsl:when test="$node/@xml:id"> |
| 98 |
<xsl:value-of select="$node/@xml:id"/> |
| 99 |
</xsl:when> |
| 100 |
<xsl:otherwise> |
| 101 |
<xsl:text>-note-</xsl:text> |
| 102 |
<xsl:value-of select="generate-id($node)"/> |
| 103 |
</xsl:otherwise> |
| 104 |
</xsl:choose> |
| 105 |
</xsl:variable> |
| 106 |
<xsl:variable name="href"> |
| 107 |
<xsl:text>#</xsl:text> |
| 108 |
<xsl:text>-noteref-</xsl:text> |
| 109 |
<xsl:choose> |
| 110 |
<xsl:when test="$node/@id"> |
| 111 |
<xsl:value-of select="$node/@id"/> |
| 112 |
</xsl:when> |
| 113 |
<xsl:when test="$node/@xml:id"> |
| 114 |
<xsl:value-of select="$node/@xml:id"/> |
| 115 |
</xsl:when> |
| 116 |
<xsl:otherwise> |
| 117 |
<xsl:value-of select="generate-id($node)"/> |
| 118 |
</xsl:otherwise> |
| 119 |
</xsl:choose> |
| 120 |
</xsl:variable> |
| 121 |
<div id="{$anchor}"> |
| 122 |
<xsl:call-template name="html.class.attr"> |
| 123 |
<xsl:with-param name="node" select="$node"/> |
| 124 |
<xsl:with-param name="class" select="'footnote'"/> |
| 125 |
</xsl:call-template> |
| 126 |
<a class="footnote" href="{$href}"> |
| 127 |
<xsl:value-of select="count($node/preceding::footnote | $node/preceding::db:footnote) + 1"/> |
| 128 |
</a> |
| 129 |
<xsl:apply-templates select="$node/node()"/> |
| 130 |
</div> |
| 131 |
</xsl:template> |
| 132 |
|
| 133 |
|
| 134 |
<!--**========================================================================== |
| 135 |
db2html.footnote.footer |
| 136 |
Output all footnotes for a page. |
| 137 |
@revision[version=3.4 date=2011-11-10 status=final] |
| 138 |
|
| 139 |
[xsl:params] |
| 140 |
$node: The division-level element containing footnotes |
| 141 |
$depth_of_chunk: The depth of the containing chunk in the document. |
| 142 |
|
| 143 |
This template collects all `footnote` elements under $node and outputs them |
| 144 |
with {db2html.footnote.note}. It checks if each footnote would be displayed on |
| 145 |
a separate page by a child division-level element, and if so, it doesn't output |
| 146 |
that footnote. |
| 147 |
--> |
| 148 |
<xsl:template name="db2html.footnote.footer"> |
| 149 |
<xsl:param name="node" select="."/> |
| 150 |
<xsl:param name="depth_of_chunk"> |
| 151 |
<xsl:call-template name="db.chunk.depth-of-chunk"/> |
| 152 |
</xsl:param> |
| 153 |
<xsl:variable name="notes" select="$node//footnote | $node//db:footnote" /> |
| 154 |
<xsl:variable name="include"> |
| 155 |
<xsl:for-each select="$notes"> |
| 156 |
<xsl:variable name="depth"> |
| 157 |
<xsl:call-template name="db.chunk.depth-of-chunk"/> |
| 158 |
</xsl:variable> |
| 159 |
<xsl:choose> |
| 160 |
<xsl:when test="$depth = $depth_of_chunk"> |
| 161 |
<xsl:text>y</xsl:text> |
| 162 |
</xsl:when> |
| 163 |
<xsl:otherwise> |
| 164 |
<xsl:text>x</xsl:text> |
| 165 |
</xsl:otherwise> |
| 166 |
</xsl:choose> |
| 167 |
</xsl:for-each> |
| 168 |
</xsl:variable> |
| 169 |
<xsl:if test="contains($include, 'y')"> |
| 170 |
<div class="footnotes"> |
| 171 |
<xsl:for-each select="$notes"> |
| 172 |
<xsl:if test="substring($include, position(), 1) = 'y'"> |
| 173 |
<xsl:call-template name="db2html.footnote.note"> |
| 174 |
<xsl:with-param name="node" select="."/> |
| 175 |
</xsl:call-template> |
| 176 |
</xsl:if> |
| 177 |
</xsl:for-each> |
| 178 |
</div> |
| 179 |
</xsl:if> |
| 180 |
</xsl:template> |
| 181 |
|
| 182 |
</xsl:stylesheet> |