1 <?xml version="1.0" encoding="utf-8"?>
4 This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5 Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
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/" >
12 <xsl:output encoding="utf-8" method="text" />
14 <xsl:param name="wrapping" select="0" />
16 <!-- ============================================================================== -->
17 <!-- = MASTER TAG = -->
18 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
19 <!-- ============================================================================== -->
20 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
21 <xsl:if test="not (../@raw-text) and nazwa_utworu">
22 <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
23 <xsl:call-template name="translators" />
27 <xsl:apply-templates />
34 <!-- ==================================================================================== -->
35 <!-- = BLOCK TAGS = -->
36 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
37 <!-- ==================================================================================== -->
38 <xsl:template match="nota">
39 <xsl:apply-templates />
42 <xsl:template match="lista_osob">
47 <xsl:value-of select="naglowek_listy" />
48 <xsl:apply-templates select="lista_osoba" />
53 <xsl:template match="dedykacja">
57 <xsl:apply-templates />
60 <xsl:template match="kwestia">
61 <xsl:apply-templates select="strofa|akap|didaskalia" />
64 <xsl:template match="dlugi_cytat|poezja_cyt">
67 <xsl:apply-templates />
70 <xsl:template match="motto">
76 <xsl:apply-templates /><xsl:text>
82 <!-- ========================================== -->
83 <!-- = PARAGRAPH TAGS = -->
84 <!-- = (can contain inline and special tags) = -->
85 <!-- ========================================== -->
87 <xsl:template match="autor_utworu" mode="header">
88 <xsl:apply-templates mode="inline" />
94 <xsl:template match="nazwa_utworu" mode="header">
95 <xsl:apply-templates mode="inline" />
100 <xsl:template match="dzielo_nadrzedne" mode="header">
101 <xsl:apply-templates mode="inline" />
106 <xsl:template match="podtytul" mode="header">
107 <xsl:apply-templates mode="inline" />
112 <!-- Section headers (included in index)-->
113 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
120 <xsl:apply-templates mode="inline" />
123 <xsl:template match="naglowek_scena|naglowek_rozdzial">
129 <xsl:apply-templates mode="inline" />
132 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
137 <xsl:apply-templates mode="inline" />
140 <!-- Other paragraph tags -->
141 <xsl:template match="miejsce_czas">
147 <xsl:apply-templates mode="inline" />
150 <xsl:template match="didaskalia">
151 <xsl:variable name="content">
152 <xsl:apply-templates select="*|text()" mode="inline" />
156 / </xsl:text><xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" /><xsl:text> /</xsl:text>
159 <xsl:template match="lista_osoba">
162 <xsl:apply-templates mode="inline" />
165 <xsl:template match="akap|akap_dialog|akap_cd">
166 <xsl:variable name="content">
167 <xsl:apply-templates select="*|text()" mode="inline" />
172 <xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" />
175 <xsl:template match="strofa">
179 <xsl:when test="count(br) > 0">
180 <xsl:call-template name="verse">
181 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
182 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
184 <xsl:for-each select="br">
185 <!-- Each BR tag "consumes" text after it -->
186 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
187 <xsl:call-template name="verse">
188 <xsl:with-param name="verse-content"
189 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
190 <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
195 <xsl:call-template name="verse">
196 <xsl:with-param name="verse-content" select="text() | node()" />
197 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
203 <xsl:template name="verse">
204 <xsl:param name="verse-content" />
205 <xsl:param name="verse-type" />
208 <xsl:variable name="content">
209 <xsl:apply-templates select="$verse-content" mode="inline" />
212 <xsl:when test="name($verse-type) = 'wers_akap'">
213 <xsl:text> </xsl:text>
215 <xsl:when test="name($verse-type) = 'wers_wciety'">
217 <xsl:when test="$verse-content/@typ">
218 <xsl:text> </xsl:text>
221 <xsl:text> </xsl:text>
225 <xsl:when test="name($verse-type) = 'wers_cd'">
226 <xsl:text> </xsl:text>
229 <xsl:value-of select="wl:strip($content)" />
232 <xsl:template match="motto_podpis">
233 <xsl:apply-templates mode="inline" />
237 <!-- ================================================ -->
238 <!-- = INLINE TAGS = -->
239 <!-- = (contain other inline tags and special tags) = -->
240 <!-- ================================================ -->
242 <xsl:template match="pa|pe|pr|pt" mode="inline" />
244 <!-- Other inline tags -->
245 <xsl:template match="mat" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
247 <xsl:template match="didask_tekst" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
249 <xsl:template match="slowo_obce" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
251 <xsl:template match="tytul_dziela" mode="inline">
252 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
255 <xsl:template match="wyroznienie" mode="inline">
256 <xsl:text>*</xsl:text><xsl:apply-templates mode="inline" /><xsl:text>*</xsl:text>
259 <xsl:template match="osoba" mode="inline">
260 <xsl:apply-templates mode="inline" />
264 <!-- ============================================== -->
265 <!-- = STANDALONE TAGS = -->
266 <!-- = (cannot contain any other tags) = -->
267 <!-- ============================================== -->
268 <xsl:template match="sekcja_swiatlo">
276 <xsl:template match="sekcja_asterysk">
284 <xsl:template match="separator_linia">
287 ------------------------------------------------
293 <!-- ================ -->
294 <!-- = SPECIAL TAGS = -->
295 <!-- ================ -->
297 <xsl:template match="begin" mode="inline" />
299 <xsl:template match="end" mode="inline" />
301 <xsl:template match="begin|end" />
303 <xsl:template match="motyw" mode="inline" />
305 <xsl:template name="translators">
306 <xsl:if test="//dc:contributor.translator">
308 <xsl:for-each select="//dc:contributor.translator/text()">
309 <xsl:if test="position() != 1">
310 <xsl:text>, </xsl:text>
312 <xsl:value-of select="wl:person_name(.)" />
320 <!-- ================ -->
321 <!-- = IGNORED TAGS = -->
322 <!-- ================ -->
323 <xsl:template match="extra|uwaga" />
324 <xsl:template match="extra|uwaga" mode="inline" />
326 <xsl:template match="nota_red" />
331 <xsl:template match="text()" />
332 <xsl:template match="text()" mode="inline">
333 <xsl:value-of select="wl:substitute_entities(.)" />