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

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/lrf/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
 
                                <!-- BUILD BOOK -->
64
 
                                <xsl:for-each select="fb:body">
65
 
                                        <xsl:if test="position()!=1">
66
 
                                                <hr/>
67
 
                                        </xsl:if>
68
 
                                        <xsl:if test="@name">
69
 
                                                <h4 align="center">
70
 
                                                        <xsl:value-of select="@name"/>
71
 
                                                </h4>
72
 
                                        </xsl:if>
73
 
                                        <!-- <xsl:apply-templates /> -->
74
 
                                        <xsl:apply-templates/>
75
 
                                </xsl:for-each>
76
 
                        </body>
77
 
                </html>
78
 
        </xsl:template>
79
 
        <!-- author template -->
80
 
        <xsl:template name="author">
81
 
                <xsl:value-of select="fb:first-name"/>
82
 
                <xsl:text disable-output-escaping="no">&#032;</xsl:text>
83
 
                <xsl:value-of select="fb:middle-name"/>&#032;
84
 
         <xsl:text disable-output-escaping="no">&#032;</xsl:text>
85
 
                <xsl:value-of select="fb:last-name"/>
86
 
                <br/>
87
 
        </xsl:template>
88
 
        <!-- secuence template -->
89
 
        <xsl:template name="sequence">
90
 
                <LI/>
91
 
                <xsl:value-of select="@name"/>
92
 
                <xsl:if test="@number">
93
 
                        <xsl:text disable-output-escaping="no">,&#032;#</xsl:text>
94
 
                        <xsl:value-of select="@number"/>
95
 
                </xsl:if>
96
 
                <xsl:if test="fb:sequence">
97
 
                        <ul>
98
 
                                <xsl:for-each select="fb:sequence">
99
 
                                        <xsl:call-template name="sequence"/>
100
 
                                </xsl:for-each>
101
 
                        </ul>
102
 
                </xsl:if>
103
 
                <!--      <br/> -->
104
 
        </xsl:template>
105
 
        <!-- toc template -->
106
 
        <xsl:template match="fb:section|fb:body" mode="toc">
107
 
                <xsl:choose>
108
 
                        <xsl:when test="name()='body' and position()=1 and not(fb:title)">
109
 
                                <xsl:apply-templates select="fb:section" mode="toc"/>
110
 
                        </xsl:when>
111
 
                        <xsl:otherwise>
112
 
                                <li>
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>
116
 
                                        </xsl:if>
117
 
                                </li>
118
 
                        </xsl:otherwise>
119
 
                </xsl:choose>
120
 
        </xsl:template>
121
 
        <!-- description -->
122
 
        <xsl:template match="fb:description">
123
 
                <xsl:apply-templates/>
124
 
        </xsl:template>
125
 
        <!-- body -->
126
 
        <xsl:template match="fb:body">
127
 
                <div><xsl:apply-templates/></div>
128
 
        </xsl:template>
129
 
 
130
 
        <xsl:template match="fb:section">
131
 
        <xsl:variable name="section_has_title">
132
 
            <xsl:choose>
133
 
                <xsl:when test="./fb:title"><xsl:value-of select="generate-id()" /></xsl:when>
134
 
                <xsl:otherwise>None</xsl:otherwise>
135
 
            </xsl:choose>
136
 
        </xsl:variable>
137
 
        <xsl:if test="$section_has_title = 'None'">
138
 
            <a name="TOC_{generate-id()}" />
139
 
            <xsl:if test="@id">
140
 
                <xsl:element name="a">
141
 
                    <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
142
 
                </xsl:element>
143
 
            </xsl:if>
144
 
        </xsl:if>
145
 
        <xsl:apply-templates>
146
 
            <xsl:with-param name="section_toc_id" select="$section_has_title" />
147
 
        </xsl:apply-templates>
148
 
        </xsl:template>
149
 
        
150
 
        
151
 
        <!-- section/title -->
152
 
        <xsl:template match="fb:section/fb:title|fb:poem/fb:title">
153
 
        <xsl:param name="section_toc_id" />
154
 
                <xsl:choose>
155
 
                        <xsl:when test="count(ancestor::node()) &lt; 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>
159
 
                    </xsl:if>
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>
163
 
                        </xsl:element>
164
 
                    </xsl:if>
165
 
                                        <a name="TOC_{generate-id()}"></a>
166
 
                                        <xsl:if test="@id">
167
 
                                                <xsl:element name="a">
168
 
                                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
169
 
                                                </xsl:element>
170
 
                                        </xsl:if>
171
 
                                        <xsl:apply-templates/>
172
 
                                </xsl:element>
173
 
                        </xsl:when>
174
 
                        <xsl:otherwise>
175
 
                                <xsl:element name="h6">
176
 
                                        <xsl:if test="@id">
177
 
                                                <xsl:element name="a">
178
 
                                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
179
 
                                                </xsl:element>
180
 
                                        </xsl:if>
181
 
                                        <xsl:apply-templates/>
182
 
                                </xsl:element>
183
 
                        </xsl:otherwise>
184
 
                </xsl:choose>
185
 
        </xsl:template>
186
 
        <!-- section/title -->
187
 
        <xsl:template match="fb:body/fb:title">
188
 
        <xsl:element name="h1">
189
 
            <xsl:apply-templates mode="title"/>
190
 
        </xsl:element>
191
 
        </xsl:template>
192
 
 
193
 
        <xsl:template match="fb:title/fb:p">
194
 
                <xsl:apply-templates/><xsl:text disable-output-escaping="no">&#032;</xsl:text><br/>
195
 
        </xsl:template>
196
 
        <!-- subtitle -->
197
 
        <xsl:template match="fb:subtitle">
198
 
                <xsl:if test="@id">
199
 
                        <xsl:element name="a">
200
 
                                <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
201
 
                        </xsl:element>
202
 
                </xsl:if>
203
 
                <h5>
204
 
                        <xsl:apply-templates/>
205
 
                </h5>
206
 
        </xsl:template>
207
 
        <!-- p -->
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>
212
 
                                </xsl:element>
213
 
                        </xsl:if>       &#160;&#160;&#160;<xsl:apply-templates/></div>
214
 
        </xsl:template>
215
 
        <!-- strong -->
216
 
        <xsl:template match="fb:strong">
217
 
                <b><xsl:apply-templates/></b>
218
 
        </xsl:template>
219
 
        <!-- emphasis -->
220
 
        <xsl:template match="fb:emphasis">
221
 
                <i>     <xsl:apply-templates/></i>
222
 
        </xsl:template>
223
 
        <!-- style -->
224
 
        <xsl:template match="fb:style">
225
 
                <span class="{@name}"><xsl:apply-templates/></span>
226
 
        </xsl:template>
227
 
        <!-- empty-line -->
228
 
        <xsl:template match="fb:empty-line">
229
 
                <br/>
230
 
        </xsl:template>
231
 
        <!-- link -->
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">
236
 
                                <xsl:choose>
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>
239
 
                                </xsl:choose>
240
 
                        </xsl:attribute>
241
 
                        <xsl:choose>
242
 
                                <xsl:when test="(@type) = 'note'">
243
 
                                        <sup>
244
 
                                                <xsl:apply-templates/>
245
 
                                        </sup>
246
 
                                </xsl:when>
247
 
                                <xsl:otherwise>
248
 
                                        <xsl:apply-templates/>
249
 
                                </xsl:otherwise>
250
 
                        </xsl:choose>
251
 
                </xsl:element>
252
 
        </xsl:template>
253
 
        <!-- annotation -->
254
 
        <xsl:template name="annotation">
255
 
                <xsl:if test="@id">
256
 
                        <xsl:element name="a">
257
 
                                <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
258
 
                        </xsl:element>
259
 
                </xsl:if>
260
 
                <h3>Annotation</h3>
261
 
                <xsl:apply-templates/>
262
 
        </xsl:template>
263
 
        <!-- epigraph -->
264
 
        <xsl:template match="fb:epigraph">
265
 
                <blockquote class="epigraph">
266
 
                        <xsl:if test="@id">
267
 
                                <xsl:element name="a">
268
 
                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
269
 
                                </xsl:element>
270
 
                        </xsl:if>
271
 
                        <xsl:apply-templates/>
272
 
                </blockquote>
273
 
        </xsl:template>
274
 
        <!-- epigraph/text-author -->
275
 
        <xsl:template match="fb:epigraph/fb:text-author">
276
 
                <blockquote>
277
 
                        <i><xsl:apply-templates/></i>
278
 
                </blockquote>
279
 
        </xsl:template>
280
 
        <!-- cite -->
281
 
        <xsl:template match="fb:cite">
282
 
                <blockquote>
283
 
                <xsl:if test="@id">
284
 
                        <xsl:element name="a">
285
 
                                <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
286
 
                        </xsl:element>
287
 
                </xsl:if>
288
 
                <xsl:apply-templates/>
289
 
                </blockquote>
290
 
        </xsl:template>
291
 
        <!-- cite/text-author -->
292
 
        <xsl:template match="fb:text-author">
293
 
                <blockquote>
294
 
                <i>     <xsl:apply-templates/></i></blockquote>
295
 
        </xsl:template>
296
 
        <!-- date -->
297
 
        <xsl:template match="fb:date">
298
 
                <xsl:choose>
299
 
                        <xsl:when test="not(@value)">
300
 
                                &#160;&#160;&#160;<xsl:apply-templates/>
301
 
                                <br/>
302
 
                        </xsl:when>
303
 
                        <xsl:otherwise>
304
 
                                &#160;&#160;&#160;<xsl:value-of select="@value"/>
305
 
                                <br/>
306
 
                        </xsl:otherwise>
307
 
                </xsl:choose>
308
 
        </xsl:template>
309
 
        <!-- poem -->
310
 
        <xsl:template match="fb:poem">
311
 
                <blockquote>
312
 
                        <xsl:if test="@id">
313
 
                                <xsl:element name="a">
314
 
                                        <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
315
 
                                </xsl:element>
316
 
                        </xsl:if>
317
 
                        <xsl:apply-templates/>
318
 
                </blockquote>
319
 
        </xsl:template>
320
 
 
321
 
        <!-- stanza -->
322
 
        <xsl:template match="fb:stanza">
323
 
                <xsl:apply-templates/>
324
 
                <br/>
325
 
        </xsl:template>
326
 
        <!-- v -->
327
 
        <xsl:template match="fb:v">
328
 
                <xsl:if test="@id">
329
 
                        <xsl:element name="a">
330
 
                                <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
331
 
                        </xsl:element>
332
 
                </xsl:if>
333
 
                <xsl:apply-templates/><br/>
334
 
        </xsl:template>
335
 
        <!-- image -->
336
 
        <xsl:template match="fb:image">
337
 
                <div align="center">
338
 
                        <img border="1">
339
 
                                <xsl:choose>
340
 
                                        <xsl:when test="starts-with(@xlink:href,'#')">
341
 
                                                <xsl:attribute name="src"><xsl:value-of select="substring-after(@xlink:href,'#')"/></xsl:attribute>
342
 
                                        </xsl:when>
343
 
                                        <xsl:otherwise>
344
 
                                                <xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>
345
 
                                        </xsl:otherwise>
346
 
                                </xsl:choose>
347
 
                        </img>
348
 
                </div>
349
 
        </xsl:template>
350
 
</xsl:stylesheet>