1
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fb="http://www.gribuser.ru/xml/fictionbook/2.0">
3
#########################################################################
6
# copyright 2002 Paul Henry Tremblay #
8
# This program is distributed in the hope that it will be useful, #
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
11
# General Public License for more details. #
13
# You should have received a copy of the GNU General Public License #
14
# along with this program; if not, write to the Free Software #
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA #
19
#########################################################################
22
<xsl:output method="xml" encoding="UTF-8"/>
23
<xsl:key name="note-link" match="fb:section" use="@id"/>
24
<xsl:template match="/*">
27
<xsl:if test="fb:description/fb:title-info/fb:lang = 'ru'">
28
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"/>
31
<xsl:value-of select="fb:description/fb:title-info/fb:book-title"/>
33
<style type="text/x-oeb1-css">
35
A:HOVER { color : #BF0000 }
36
BODY { background-color : #FEFEFE; color : #000000; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; text-align : justify }
37
H1{ font-size : 160%; font-style : normal; font-weight : bold; text-align : left; border : 1px solid Black; background-color : #E7E7E7; margin-left : 0px; page-break-before : always; }
38
H2{ font-size : 130%; font-style : normal; font-weight : bold; text-align : left; background-color : #EEEEEE; border : 1px solid Gray; page-break-before : always; }
39
H3{ font-size : 110%; font-style : normal; font-weight : bold; text-align : left; background-color : #F1F1F1; border : 1px solid Silver;}
40
H4{ font-size : 100%; font-style : normal; font-weight : bold; text-align : left; border : 1px solid Gray; background-color : #F4F4F4;}
41
H5{ font-size : 100%; font-style : italic; font-weight : bold; text-align : left; border : 1px solid Gray; background-color : #F4F4F4;}
42
H6{ font-size : 100%; font-style : italic; font-weight : normal; text-align : left; border : 1px solid Gray; background-color : #F4F4F4;}
43
SMALL{ font-size : 80% }
44
BLOCKQUOTE{ margin-left :4em; margin-top:1em; margin-right:0.2em;}
46
DIV{font-family : "Times New Roman", Times, serif; text-align : justify}
48
.epigraph{width:50%; margin-left : 35%;}
52
<xsl:for-each select="fb:description/fb:title-info/fb:annotation">
54
<xsl:call-template name="annotation"/>
60
<xsl:apply-templates select="fb:body" mode="toc"/>
64
<xsl:for-each select="fb:body">
65
<xsl:if test="position()!=1">
70
<xsl:value-of select="@name"/>
73
<!-- <xsl:apply-templates /> -->
74
<xsl:apply-templates/>
79
<!-- author template -->
80
<xsl:template name="author">
81
<xsl:value-of select="fb:first-name"/>
82
<xsl:text disable-output-escaping="no"> </xsl:text>
83
<xsl:value-of select="fb:middle-name"/> 
84
<xsl:text disable-output-escaping="no"> </xsl:text>
85
<xsl:value-of select="fb:last-name"/>
88
<!-- secuence template -->
89
<xsl:template name="sequence">
91
<xsl:value-of select="@name"/>
92
<xsl:if test="@number">
93
<xsl:text disable-output-escaping="no">, #</xsl:text>
94
<xsl:value-of select="@number"/>
96
<xsl:if test="fb:sequence">
98
<xsl:for-each select="fb:sequence">
99
<xsl:call-template name="sequence"/>
105
<!-- toc template -->
106
<xsl:template match="fb:section|fb:body" mode="toc">
108
<xsl:when test="name()='body' and position()=1 and not(fb:title)">
109
<xsl:apply-templates select="fb:section" mode="toc"/>
113
<a href="#TOC_{generate-id()}"><xsl:value-of select="normalize-space(fb:title/fb:p[1] | @name)"/></a>
114
<xsl:if test="fb:section">
115
<ul><xsl:apply-templates select="fb:section" mode="toc"/></ul>
122
<xsl:template match="fb:description">
123
<xsl:apply-templates/>
126
<xsl:template match="fb:body">
127
<div><xsl:apply-templates/></div>
130
<xsl:template match="fb:section">
131
<xsl:variable name="section_has_title">
133
<xsl:when test="./fb:title"><xsl:value-of select="generate-id()" /></xsl:when>
134
<xsl:otherwise>None</xsl:otherwise>
137
<xsl:if test="$section_has_title = 'None'">
138
<a name="TOC_{generate-id()}" />
140
<xsl:element name="a">
141
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
145
<xsl:apply-templates>
146
<xsl:with-param name="section_toc_id" select="$section_has_title" />
147
</xsl:apply-templates>
151
<!-- section/title -->
152
<xsl:template match="fb:section/fb:title|fb:poem/fb:title">
153
<xsl:param name="section_toc_id" />
155
<xsl:when test="count(ancestor::node()) < 9">
156
<xsl:element name="{concat('h',count(ancestor::node())-3)}">
157
<xsl:if test="../@id">
158
<xsl:attribute name="id"><xsl:value-of select="../@id" /></xsl:attribute>
160
<xsl:if test="$section_toc_id != 'None'">
161
<xsl:element name="a">
162
<xsl:attribute name="name">TOC_<xsl:value-of select="$section_toc_id"/></xsl:attribute>
165
<a name="TOC_{generate-id()}"></a>
167
<xsl:element name="a">
168
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
171
<xsl:apply-templates/>
175
<xsl:element name="h6">
177
<xsl:element name="a">
178
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
181
<xsl:apply-templates/>
186
<!-- section/title -->
187
<xsl:template match="fb:body/fb:title">
188
<xsl:element name="h1">
189
<xsl:apply-templates mode="title"/>
193
<xsl:template match="fb:title/fb:p">
194
<xsl:apply-templates/><xsl:text disable-output-escaping="no"> </xsl:text><br/>
197
<xsl:template match="fb:subtitle">
199
<xsl:element name="a">
200
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
204
<xsl:apply-templates/>
208
<xsl:template match="fb:p">
209
<div align="justify"><xsl:if test="@id">
210
<xsl:element name="a">
211
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
213
</xsl:if>    <xsl:apply-templates/></div>
216
<xsl:template match="fb:strong">
217
<b><xsl:apply-templates/></b>
220
<xsl:template match="fb:emphasis">
221
<i> <xsl:apply-templates/></i>
224
<xsl:template match="fb:style">
225
<span class="{@name}"><xsl:apply-templates/></span>
228
<xsl:template match="fb:empty-line">
232
<xsl:template match="fb:a">
233
<xsl:element name="a">
234
<xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
235
<xsl:attribute name="title">
237
<xsl:when test="starts-with(@xlink:href,'#')"><xsl:value-of select="key('note-link',substring-after(@xlink:href,'#'))/fb:p"/></xsl:when>
238
<xsl:otherwise><xsl:value-of select="key('note-link',@xlink:href)/fb:p"/></xsl:otherwise>
242
<xsl:when test="(@type) = 'note'">
244
<xsl:apply-templates/>
248
<xsl:apply-templates/>
254
<xsl:template name="annotation">
256
<xsl:element name="a">
257
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
261
<xsl:apply-templates/>
264
<xsl:template match="fb:epigraph">
265
<blockquote class="epigraph">
267
<xsl:element name="a">
268
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
271
<xsl:apply-templates/>
274
<!-- epigraph/text-author -->
275
<xsl:template match="fb:epigraph/fb:text-author">
277
<i><xsl:apply-templates/></i>
281
<xsl:template match="fb:cite">
284
<xsl:element name="a">
285
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
288
<xsl:apply-templates/>
291
<!-- cite/text-author -->
292
<xsl:template match="fb:text-author">
294
<i> <xsl:apply-templates/></i></blockquote>
297
<xsl:template match="fb:date">
299
<xsl:when test="not(@value)">
300
   <xsl:apply-templates/>
304
   <xsl:value-of select="@value"/>
310
<xsl:template match="fb:poem">
313
<xsl:element name="a">
314
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
317
<xsl:apply-templates/>
322
<xsl:template match="fb:stanza">
323
<xsl:apply-templates/>
327
<xsl:template match="fb:v">
329
<xsl:element name="a">
330
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
333
<xsl:apply-templates/><br/>
336
<xsl:template match="fb:image">
340
<xsl:when test="starts-with(@xlink:href,'#')">
341
<xsl:attribute name="src"><xsl:value-of select="substring-after(@xlink:href,'#')"/></xsl:attribute>
344
<xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>