915bad448e229552843b4a32d0a8c84ab2aef234
[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:dc="http://purl.org/dc/elements/1.1/"
11         xmlns="http://www.gribuser.ru/xml/fictionbook/2.0"
12         xmlns:l="http://www.w3.org/1999/xlink">
13
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         <xsl:template match="dc:*" mode="outer">
34         </xsl:template>
35
36         <!-- we can't handle lyrics nicely yet -->
37         <xsl:template match="powiesc|opowiadanie" mode="outer">
38                 <body> <!-- main body for main book flow -->
39                         <xsl:if test="autor_utworu or nazwa_utworu">
40                                 <title>
41                                         <xsl:apply-templates mode="title"
42                                                 select="autor_utworu|dzielo_nadrzedne|nazwa_utworu"/>
43                                 </title>
44                         </xsl:if>
45
46                         <xsl:variable name="sections" select="count(naglowek_rozdzial)"/>
47                         <section>
48                                 <xsl:choose>
49                                         <xsl:when test="local-name() = 'liryka_l'">
50                                                 <poem>
51                                                         <xsl:apply-templates mode="para"/>
52                                                 </poem>
53                                         </xsl:when>
54
55                                         <xsl:otherwise>
56                                                 <xsl:apply-templates mode="para"
57                                                         select="*[count(following-sibling::naglowek_rozdzial)
58                                                         = $sections]"/>
59                                         </xsl:otherwise>
60                                 </xsl:choose>
61                         </section>
62
63                         <xsl:apply-templates mode="sections"/>
64                 </body>
65         </xsl:template>
66
67         <xsl:template match="uwaga" mode="outer"/>
68         <xsl:template match="extra" mode="outer"/>
69
70         <xsl:template mode="title" match="*">
71                 <!-- title -->
72
73                 <p><xsl:apply-templates mode="inline"/></p>
74         </xsl:template>
75
76         <xsl:template match="uwaga" mode="title"/>
77         <xsl:template match="extra" mode="title"/>
78 </xsl:stylesheet>