~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/fb2/fb2.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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">
 
2
<!--
 
3
#########################################################################
 
4
#                                                                       #
 
5
#                                                                       #
 
6
#   copyright 2002 Paul Henry Tremblay                                  #
 
7
#                                                                       #
 
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.                            #
 
12
#                                                                       #
 
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            #
 
16
#   02111-1307 USA                                                      #
 
17
#                                                                       #
 
18
#                                                                       #
 
19
#########################################################################
 
20
 
 
21
-->
 
22
        <xsl:output method="xml" encoding="UTF-8"/>
 
23
        <xsl:key name="note-link" match="fb:section" use="@id"/>
 
24
        <xsl:template match="/*">
 
25
                <html>
 
26
                        <head>
 
27
                                <xsl:if test="fb:description/fb:title-info/fb:lang = 'ru'">
 
28
                                        <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"/>
 
29
                                </xsl:if>
 
30
                                <title>
 
31
                                        <xsl:value-of select="fb:description/fb:title-info/fb:book-title"/>
 
32
                                </title>
 
33
                                <style type="text/x-oeb1-css">
 
34
                                        A { color : #0002CC }
 
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;}
 
45
                                        HR{ color : Black }
 
46
                    DIV{font-family : "Times New Roman", Times, serif; text-align : justify}
 
47
                                        UL{margin-left: 0}
 
48
                                        .epigraph{width:50%; margin-left : 35%;}
 
49
                                </style>
 
50
                        </head>
 
51
                        <body>
 
52
                                <xsl:for-each select="fb:description/fb:title-info/fb:annotation">
 
53
                                        <div>
 
54
                                                <xsl:call-template name="annotation"/>
 
55
                                        </div>
 
56
                                        <hr/>
 
57
                                </xsl:for-each>
 
58
                                <!-- BUILD TOC -->
 
59
                                <ul>
 
60
                                        <xsl:apply-templates select="fb:body" mode="toc"/>
 
61
                                </ul>
 
62
                                <hr/>
 
63
                <!-- END BUILD TOC -->
 
64
                                <!-- BUILD BOOK -->
 
65
                                <xsl:for-each select="fb:body">
 
66
                                        <xsl:if test="position()!=1">
 
67
                                                <hr/>
 
68
                                        </xsl:if>
 
69
                                        <xsl:if test="@name">
 
70
                                                <h4 align="center">
 
71
                                                        <xsl:value-of select="@name"/>
 
72
                                                </h4>
 
73
                                        </xsl:if>
 
74
                                        <!-- <xsl:apply-templates /> -->
 
75
                                        <xsl:apply-templates/>
 
76
                                </xsl:for-each>
 
77
                        </body>
 
78
                </html>
 
79
        </xsl:template>
 
80
        <!-- author template -->
 
81
        <xsl:template name="author">
 
82
                <xsl:value-of select="fb:first-name"/>
 
83
                <xsl:text disable-output-escaping="no">&#032;</xsl:text>
 
84
                <xsl:value-of select="fb:middle-name"/>&#032;
 
85
         <xsl:text disable-output-escaping="no">&#032;</xsl:text>
 
86
                <xsl:value-of select="fb:last-name"/>
 
87
                <br/>
 
88
        </xsl:template>
 
89
        <!-- secuence template -->
 
90
        <xsl:template name="sequence">
 
91
                <LI/>
 
92
                <xsl:value-of select="@name"/>
 
93
                <xsl:if test="@number">
 
94
                        <xsl:text disable-output-escaping="no">,&#032;#</xsl:text>
 
95
                        <xsl:value-of select="@number"/>
 
96
                </xsl:if>
 
97
                <xsl:if test="fb:sequence">
 
98
                        <ul>
 
99
                                <xsl:for-each select="fb:sequence">
 
100
                                        <xsl:call-template name="sequence"/>
 
101
                                </xsl:for-each>
 
102
                        </ul>
 
103
                </xsl:if>
 
104
                <!--      <br/> -->
 
105
        </xsl:template>
 
106
        <!-- toc template -->
 
107
        <xsl:template match="fb:section|fb:body" mode="toc">
 
108
                <xsl:choose>
 
109
                        <xsl:when test="name()='body' and position()=1 and not(fb:title)">
 
110
                                <xsl:apply-templates select="fb:section" mode="toc"/>
 
111
                        </xsl:when>
 
112
                        <xsl:otherwise>
 
113
                                <li>
 
114
                                        <a href="#TOC_{generate-id()}"><xsl:value-of select="normalize-space(fb:title/fb:p[1] | @name)"/></a>
 
115
                                        <xsl:if test="fb:section">
 
116
                                                <ul><xsl:apply-templates select="fb:section" mode="toc"/></ul>
 
117
                                        </xsl:if>
 
118
                                </li>
 
119
                        </xsl:otherwise>
 
120
                </xsl:choose>
 
121
        </xsl:template>
 
122
        <!-- description -->
 
123
        <xsl:template match="fb:description">
 
124
                <xsl:apply-templates/>
 
125
        </xsl:template>
 
126
        <!-- body -->
 
127
        <xsl:template match="fb:body">
 
128
                <div><xsl:apply-templates/></div>
 
129
        </xsl:template>
 
130
 
 
131
        <xsl:template match="fb:section">
 
132
        <xsl:variable name="section_has_title">
 
133
            <xsl:choose>
 
134
                <xsl:when test="./fb:title"><xsl:value-of select="generate-id()" /></xsl:when>
 
135
                <xsl:otherwise>None</xsl:otherwise>
 
136
            </xsl:choose>
 
137
        </xsl:variable>
 
138
        <xsl:if test="$section_has_title = 'None'">
 
139
            <a name="TOC_{generate-id()}" />
 
140
            <xsl:if test="@id">
 
141
                <xsl:element name="a">
 
142
                    <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
143
                </xsl:element>
 
144
            </xsl:if>
 
145
        </xsl:if>
 
146
        <xsl:apply-templates>
 
147
            <xsl:with-param name="section_toc_id" select="$section_has_title" />
 
148
        </xsl:apply-templates>
 
149
        </xsl:template>
 
150
        
 
151
        
 
152
        <!-- section/title -->
 
153
        <xsl:template match="fb:section/fb:title|fb:poem/fb:title">
 
154
        <xsl:param name="section_toc_id" />
 
155
                <xsl:choose>
 
156
                        <xsl:when test="count(ancestor::node()) &lt; 9">
 
157
                                <xsl:element name="{concat('h',count(ancestor::node())-3)}">
 
158
                    <xsl:if test="../@id">
 
159
                        <xsl:attribute name="id"><xsl:value-of select="../@id" /></xsl:attribute>
 
160
                    </xsl:if>
 
161
                    <xsl:if test="$section_toc_id != 'None'">
 
162
                        <xsl:element name="a">
 
163
                            <xsl:attribute name="name">TOC_<xsl:value-of select="$section_toc_id"/></xsl:attribute>
 
164
                        </xsl:element>
 
165
                    </xsl:if>
 
166
                                        <a name="TOC_{generate-id()}"></a>
 
167
                                        <xsl:if test="@id">
 
168
                                                <xsl:element name="a">
 
169
                                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
170
                                                </xsl:element>
 
171
                                        </xsl:if>
 
172
                                        <xsl:apply-templates/>
 
173
                                </xsl:element>
 
174
                        </xsl:when>
 
175
                        <xsl:otherwise>
 
176
                                <xsl:element name="h6">
 
177
                                        <xsl:if test="@id">
 
178
                                                <xsl:element name="a">
 
179
                                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
180
                                                </xsl:element>
 
181
                                        </xsl:if>
 
182
                                        <xsl:apply-templates/>
 
183
                                </xsl:element>
 
184
                        </xsl:otherwise>
 
185
                </xsl:choose>
 
186
        </xsl:template>
 
187
        <!-- section/title -->
 
188
        <xsl:template match="fb:body/fb:title">
 
189
        <xsl:element name="h1">
 
190
            <xsl:apply-templates mode="title"/>
 
191
        </xsl:element>
 
192
        </xsl:template>
 
193
 
 
194
        <xsl:template match="fb:title/fb:p">
 
195
                <xsl:apply-templates/><xsl:text disable-output-escaping="no">&#032;</xsl:text><br/>
 
196
        </xsl:template>
 
197
        <!-- subtitle -->
 
198
        <xsl:template match="fb:subtitle">
 
199
                <xsl:if test="@id">
 
200
                        <xsl:element name="a">
 
201
                                <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
202
                        </xsl:element>
 
203
                </xsl:if>
 
204
                <h5>
 
205
                        <xsl:apply-templates/>
 
206
                </h5>
 
207
        </xsl:template>
 
208
        <!-- p -->
 
209
        <xsl:template match="fb:p">
 
210
                <div align="justify"><xsl:if test="@id">
 
211
                                <xsl:element name="a">
 
212
                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
213
                                </xsl:element>
 
214
                        </xsl:if>       &#160;&#160;&#160;<xsl:apply-templates/></div>
 
215
        </xsl:template>
 
216
        <!-- strong -->
 
217
        <xsl:template match="fb:strong">
 
218
                <b><xsl:apply-templates/></b>
 
219
        </xsl:template>
 
220
        <!-- emphasis -->
 
221
        <xsl:template match="fb:emphasis">
 
222
                <i>     <xsl:apply-templates/></i>
 
223
        </xsl:template>
 
224
        <!-- style -->
 
225
        <xsl:template match="fb:style">
 
226
                <span class="{@name}"><xsl:apply-templates/></span>
 
227
        </xsl:template>
 
228
        <!-- empty-line -->
 
229
        <xsl:template match="fb:empty-line">
 
230
                <br/>
 
231
        </xsl:template>
 
232
        <!-- link -->
 
233
        <xsl:template match="fb:a">
 
234
                <xsl:element name="a">
 
235
                        <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
 
236
                        <xsl:attribute name="title">
 
237
                                <xsl:choose>
 
238
                                        <xsl:when test="starts-with(@xlink:href,'#')"><xsl:value-of select="key('note-link',substring-after(@xlink:href,'#'))/fb:p"/></xsl:when>
 
239
                                        <xsl:otherwise><xsl:value-of select="key('note-link',@xlink:href)/fb:p"/></xsl:otherwise>
 
240
                                </xsl:choose>
 
241
                        </xsl:attribute>
 
242
                        <xsl:choose>
 
243
                                <xsl:when test="(@type) = 'note'">
 
244
                                        <sup>
 
245
                                                <xsl:apply-templates/>
 
246
                                        </sup>
 
247
                                </xsl:when>
 
248
                                <xsl:otherwise>
 
249
                                        <xsl:apply-templates/>
 
250
                                </xsl:otherwise>
 
251
                        </xsl:choose>
 
252
                </xsl:element>
 
253
        </xsl:template>
 
254
        <!-- annotation -->
 
255
        <xsl:template name="annotation">
 
256
                <xsl:if test="@id">
 
257
                        <xsl:element name="a">
 
258
                                <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
259
                        </xsl:element>
 
260
                </xsl:if>
 
261
                <h3>Annotation</h3>
 
262
                <xsl:apply-templates/>
 
263
        </xsl:template>
 
264
        <!-- epigraph -->
 
265
        <xsl:template match="fb:epigraph">
 
266
                <blockquote class="epigraph">
 
267
                        <xsl:if test="@id">
 
268
                                <xsl:element name="a">
 
269
                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
270
                                </xsl:element>
 
271
                        </xsl:if>
 
272
                        <xsl:apply-templates/>
 
273
                </blockquote>
 
274
        </xsl:template>
 
275
        <!-- epigraph/text-author -->
 
276
        <xsl:template match="fb:epigraph/fb:text-author">
 
277
                <blockquote>
 
278
                        <i><xsl:apply-templates/></i>
 
279
                </blockquote>
 
280
        </xsl:template>
 
281
        <!-- cite -->
 
282
        <xsl:template match="fb:cite">
 
283
                <blockquote>
 
284
                <xsl:if test="@id">
 
285
                        <xsl:element name="a">
 
286
                                <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
287
                        </xsl:element>
 
288
                </xsl:if>
 
289
                <xsl:apply-templates/>
 
290
                </blockquote>
 
291
        </xsl:template>
 
292
        <!-- cite/text-author -->
 
293
        <xsl:template match="fb:text-author">
 
294
                <blockquote>
 
295
                <i>     <xsl:apply-templates/></i></blockquote>
 
296
        </xsl:template>
 
297
        <!-- date -->
 
298
        <xsl:template match="fb:date">
 
299
                <xsl:choose>
 
300
                        <xsl:when test="not(@value)">
 
301
                                &#160;&#160;&#160;<xsl:apply-templates/>
 
302
                                <br/>
 
303
                        </xsl:when>
 
304
                        <xsl:otherwise>
 
305
                                &#160;&#160;&#160;<xsl:value-of select="@value"/>
 
306
                                <br/>
 
307
                        </xsl:otherwise>
 
308
                </xsl:choose>
 
309
        </xsl:template>
 
310
        <!-- poem -->
 
311
        <xsl:template match="fb:poem">
 
312
                <blockquote>
 
313
                        <xsl:if test="@id">
 
314
                                <xsl:element name="a">
 
315
                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
316
                                </xsl:element>
 
317
                        </xsl:if>
 
318
                        <xsl:apply-templates/>
 
319
                </blockquote>
 
320
        </xsl:template>
 
321
 
 
322
        <!-- stanza -->
 
323
        <xsl:template match="fb:stanza">
 
324
                <xsl:apply-templates/>
 
325
                <br/>
 
326
        </xsl:template>
 
327
        <!-- v -->
 
328
        <xsl:template match="fb:v">
 
329
                <xsl:if test="@id">
 
330
                        <xsl:element name="a">
 
331
                                <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
 
332
                        </xsl:element>
 
333
                </xsl:if>
 
334
                <xsl:apply-templates/><br/>
 
335
        </xsl:template>
 
336
        <!-- image -->
 
337
        <xsl:template match="fb:image">
 
338
                <div align="center">
 
339
                        <img border="1">
 
340
                                <xsl:choose>
 
341
                                        <xsl:when test="starts-with(@xlink:href,'#')">
 
342
                                                <xsl:attribute name="src"><xsl:value-of select="substring-after(@xlink:href,'#')"/></xsl:attribute>
 
343
                                        </xsl:when>
 
344
                                        <xsl:otherwise>
 
345
                                                <xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>
 
346
                                        </xsl:otherwise>
 
347
                                </xsl:choose>
 
348
                        </img>
 
349
                </div>
 
350
        </xsl:template>
 
351
</xsl:stylesheet>