Allow using remote cache for image downloading. Also, DRY in book2* scripts
[librarian.git] / librarian / fb2 / fb2.xslt
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3
4         This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5         Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6
7 -->
8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9         xmlns:wl="http://wolnelektury.pl/functions"
10         xmlns="http://www.gribuser.ru/xml/fictionbook/2.0"
11         xmlns:l="http://www.w3.org/1999/xlink">
12
13         <xsl:include href="description.xslt"/>
14         <xsl:include href="footnotes.xslt"/>
15         <xsl:include href="inline.xslt"/>
16         <xsl:include href="paragraphs.xslt"/>
17         <xsl:include href="poems.xslt"/>
18         <xsl:include href="sections.xslt"/>
19
20         <xsl:strip-space elements="*"/>
21         <xsl:output encoding="utf-8" method="xml" indent="yes"/>
22
23         <xsl:template match="utwor">
24                 <FictionBook>
25                         <xsl:apply-templates mode="outer"/>
26
27                         <body name="footnotes">
28                                 <xsl:apply-templates mode="footnotes"/>
29                         </body>
30                 </FictionBook>
31         </xsl:template>
32
33         <!-- we can't handle lyrics nicely yet -->
34         <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp" mode="outer">
35                 <body> <!-- main body for main book flow -->
36                         <xsl:if test="autor_utworu or nazwa_utworu">
37                                 <title>
38                                         <xsl:apply-templates mode="title"
39                                                 select="autor_utworu|dzielo_nadrzedne|nazwa_utworu"/>
40                                 </title>
41                         </xsl:if>
42
43                         <epigraph>
44                                 <p>
45                                         Utwór opracowany został w&#160;ramach projektu
46                                                 <a l:href="http://www.wolnelektury.pl/">Wolne Lektury</a>
47                                         przez <a l:href="http://www.nowoczesnapolska.org.pl/">fundację
48                                                 Nowoczesna Polska</a>.
49                                 </p>
50                         </epigraph>
51
52                         <xsl:variable name="sections" select="count(naglowek_rozdzial)"/>
53                         <section>
54                                 <xsl:choose>
55                                         <xsl:when test="local-name() = 'liryka_l'">
56                                                 <poem>
57                                                         <xsl:apply-templates mode="para"/>
58                                                 </poem>
59                                         </xsl:when>
60
61                                         <xsl:otherwise>
62                                                 <xsl:apply-templates mode="para"
63                                                         select="*[count(following-sibling::naglowek_rozdzial)
64                                                         = $sections]"/>
65                                         </xsl:otherwise>
66                                 </xsl:choose>
67                         </section>
68
69                         <xsl:apply-templates mode="sections"/>
70                 </body>
71         </xsl:template>
72
73         <xsl:template match="uwaga" mode="outer"/>
74         <xsl:template match="extra" mode="outer"/>
75
76         <xsl:template mode="title" match="*">
77                 <!-- title -->
78
79                 <p><xsl:apply-templates mode="inline"/></p>
80         </xsl:template>
81
82         <xsl:template match="uwaga" mode="title"/>
83         <xsl:template match="extra" mode="title"/>
84 </xsl:stylesheet>