77716e37d590ef96cfc3de4e2a2e1f6e0bad786f
[librarian.git] / librarian / fb2 / poems.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         <!-- poems -->
15
16         <!-- match poem citations -->
17         <xsl:template mode="paras" match="poezja_cyt">
18                 <cite>
19                         <poem>
20                                 <xsl:apply-templates mode="poem"/>
21                         </poem>
22                 </cite>
23         </xsl:template>
24         <!-- / XXX: fb2 doesn't allow <poem/> inside <p/> /
25         <xsl:template mode="inline" match="poezja_cyt">
26
27                 <poem>
28                         <xsl:apply-templates mode="poem"/>
29                 </poem>
30         </xsl:template>
31         -->
32
33         <!-- regular poem elements -->
34         <xsl:template mode="poem" match="strofa">
35                 <stanza>
36                         <xsl:call-template name="split-poem">
37                                 <xsl:with-param name="list" select="."/>
38                         </xsl:call-template>
39                 </stanza>
40         </xsl:template>
41
42         <!-- split into verses -->
43         <xsl:template name="split-poem">
44                 <xsl:param name="list"></xsl:param>
45
46                 <xsl:if test="$list != ''">
47                         <xsl:variable name="before"
48                                 select="substring-before(concat($list, '/'), '/')"/>
49                         <xsl:variable name="after"
50                                 select="substring-after($list, '/')"/>
51
52                         <v>
53                                 <xsl:value-of select="$before"/>
54                         </v>
55
56                         <xsl:call-template name="split-poem">
57                                 <xsl:with-param name="list" select="$after"/>
58                         </xsl:call-template>
59                 </xsl:if>
60         </xsl:template>
61
62         <xsl:template match="text()" mode="poem"/>
63 </xsl:stylesheet>