source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/footnote.xsl@ 590ddeb

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 590ddeb was d7c9f58, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Updated DocBook-XSL code to version 1.73.2

  • Property mode set to 100644
File size: 6.6 KB
Line 
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"
4 xmlns:exsl="http://exslt.org/common"
5 exclude-result-prefixes="exsl"
6 version='1.0'>
7
8<!-- ********************************************************************
9 $Id$
10 ********************************************************************
11
12 This file is part of the XSL DocBook Stylesheet distribution.
13 See ../README or http://docbook.sf.net/release/xsl/current/ for
14 copyright and other information.
15
16 ******************************************************************** -->
17
18<xsl:template name="format.footnote.mark">
19 <xsl:param name="mark" select="'?'"/>
20 <fo:inline xsl:use-attribute-sets="footnote.mark.properties">
21 <xsl:choose>
22 <xsl:when test="$fop.extensions != 0">
23 <xsl:attribute name="vertical-align">super</xsl:attribute>
24 </xsl:when>
25 <xsl:otherwise>
26 <xsl:attribute name="baseline-shift">super</xsl:attribute>
27 </xsl:otherwise>
28 </xsl:choose>
29 <xsl:copy-of select="$mark"/>
30 </fo:inline>
31</xsl:template>
32
33<xsl:template match="footnote">
34 <xsl:choose>
35 <xsl:when test="ancestor::table or ancestor::informaltable">
36 <xsl:call-template name="format.footnote.mark">
37 <xsl:with-param name="mark">
38 <xsl:apply-templates select="." mode="footnote.number"/>
39 </xsl:with-param>
40 </xsl:call-template>
41 </xsl:when>
42 <xsl:otherwise>
43 <fo:footnote>
44 <fo:inline>
45 <xsl:call-template name="format.footnote.mark">
46 <xsl:with-param name="mark">
47 <xsl:apply-templates select="." mode="footnote.number"/>
48 </xsl:with-param>
49 </xsl:call-template>
50 </fo:inline>
51 <fo:footnote-body xsl:use-attribute-sets="footnote.properties">
52 <xsl:apply-templates/>
53 </fo:footnote-body>
54 </fo:footnote>
55 </xsl:otherwise>
56 </xsl:choose>
57</xsl:template>
58
59<xsl:template match="footnoteref">
60 <xsl:variable name="footnote" select="key('id',@linkend)"/>
61 <xsl:call-template name="format.footnote.mark">
62 <xsl:with-param name="mark">
63 <xsl:apply-templates select="$footnote" mode="footnote.number"/>
64 </xsl:with-param>
65 </xsl:call-template>
66</xsl:template>
67
68<xsl:template match="footnote" mode="footnote.number">
69 <xsl:choose>
70 <xsl:when test="string-length(@label) != 0">
71 <xsl:value-of select="@label"/>
72 </xsl:when>
73 <xsl:when test="ancestor::table or ancestor::informaltable">
74 <xsl:variable name="tfnum">
75 <xsl:number level="any" from="table|informaltable" format="1"/>
76 </xsl:variable>
77
78 <xsl:choose>
79 <xsl:when test="string-length($table.footnote.number.symbols) &gt;= $tfnum">
80 <xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
81 </xsl:when>
82 <xsl:otherwise>
83 <xsl:number level="any" from="table|informaltable"
84 format="{$table.footnote.number.format}"/>
85 </xsl:otherwise>
86 </xsl:choose>
87 </xsl:when>
88 <xsl:otherwise>
89 <xsl:variable name="fnum">
90 <!-- FIXME: list in @from is probably not complete -->
91 <xsl:number level="any"
92 from="chapter|appendix|preface|article|refentry|bibliography"
93 count="footnote[not(@label)][not(ancestor::table) and not(ancestor::informaltable)]|ulink[$ulink.footnotes != 0][node()][@url != .][not(ancestor::footnote)][$ulink.show != 0]"
94 format="1"/>
95 </xsl:variable>
96 <xsl:choose>
97 <xsl:when test="string-length($footnote.number.symbols) &gt;= $fnum">
98 <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
99 </xsl:when>
100 <xsl:otherwise>
101 <xsl:number value="$fnum" format="{$footnote.number.format}"/>
102 </xsl:otherwise>
103 </xsl:choose>
104 </xsl:otherwise>
105 </xsl:choose>
106</xsl:template>
107
108<!-- ==================================================================== -->
109
110<xsl:template match="*" mode="footnote.body.number">
111 <xsl:variable name="footnote.mark">
112 <xsl:call-template name="format.footnote.mark">
113 <xsl:with-param name="mark">
114 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
115 </xsl:with-param>
116 </xsl:call-template>
117 </xsl:variable>
118
119 <xsl:variable name="fo">
120 <xsl:apply-templates select="."/>
121 </xsl:variable>
122
123 <xsl:variable name="fo-nodes" select="exsl:node-set($fo)"/>
124
125 <xsl:choose>
126 <xsl:when test="$fo-nodes//fo:block">
127 <xsl:apply-templates select="$fo-nodes" mode="insert.fo.fnum">
128 <xsl:with-param name="mark" select="$footnote.mark"/>
129 </xsl:apply-templates>
130 </xsl:when>
131 <xsl:otherwise>
132 <xsl:apply-templates select="$fo-nodes" mode="insert.fo.text">
133 <xsl:with-param name="mark" select="$footnote.mark"/>
134 </xsl:apply-templates>
135 </xsl:otherwise>
136 </xsl:choose>
137</xsl:template>
138
139<!-- ==================================================================== -->
140
141<xsl:template match="footnote/para[1]
142 |footnote/simpara[1]
143 |footnote/formalpara[1]"
144 priority="2">
145 <!-- this only works if the first thing in a footnote is a para, -->
146 <!-- which is ok, because it usually is. -->
147 <fo:block>
148 <xsl:call-template name="format.footnote.mark">
149 <xsl:with-param name="mark">
150 <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
151 </xsl:with-param>
152 </xsl:call-template>
153 <xsl:apply-templates/>
154 </fo:block>
155</xsl:template>
156
157<xsl:template match="footnote" mode="table.footnote.mode">
158 <xsl:choose>
159 <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
160 <fo:block xsl:use-attribute-sets="table.footnote.properties">
161 <xsl:apply-templates/>
162 </fo:block>
163 </xsl:when>
164
165 <xsl:when test="function-available('exsl:node-set')">
166 <fo:block xsl:use-attribute-sets="table.footnote.properties">
167 <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
168 <xsl:apply-templates select="*[position() &gt; 1]"/>
169 </fo:block>
170 </xsl:when>
171
172 <xsl:otherwise>
173 <xsl:message>
174 <xsl:text>Warning: footnote number may not be generated </xsl:text>
175 <xsl:text>correctly; </xsl:text>
176 <xsl:value-of select="local-name(*[1])"/>
177 <xsl:text> unexpected as first child of footnote.</xsl:text>
178 </xsl:message>
179 <fo:block xsl:use-attribute-sets="table.footnote.properties">
180 <xsl:apply-templates/>
181 </fo:block>
182 </xsl:otherwise>
183 </xsl:choose>
184</xsl:template>
185
186</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.