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" />
24 <xsl:call-template name="isbn" />
28 <xsl:apply-templates />
35 <!-- ==================================================================================== -->
36 <!-- = BLOCK TAGS = -->
37 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
38 <!-- ==================================================================================== -->
39 <xsl:template match="nota">
40 <xsl:apply-templates />
43 <xsl:template match="lista_osob">
48 <xsl:value-of select="naglowek_listy" />
49 <xsl:apply-templates select="lista_osoba" />
54 <xsl:template match="dedykacja">
58 <xsl:apply-templates />
61 <xsl:template match="kwestia">
62 <xsl:apply-templates select="strofa|akap|didaskalia" />
65 <xsl:template match="dlugi_cytat|poezja_cyt">
68 <xsl:apply-templates />
71 <xsl:template match="motto">
77 <xsl:apply-templates /><xsl:text>
83 <!-- ========================================== -->
84 <!-- = PARAGRAPH TAGS = -->
85 <!-- = (can contain inline and special tags) = -->
86 <!-- ========================================== -->
88 <xsl:template match="autor_utworu" mode="header">
89 <xsl:apply-templates mode="inline" />
95 <xsl:template match="nazwa_utworu" mode="header">
96 <xsl:apply-templates mode="inline" />
101 <xsl:template match="dzielo_nadrzedne" mode="header">
102 <xsl:apply-templates mode="inline" />
107 <xsl:template match="podtytul" mode="header">
108 <xsl:apply-templates mode="inline" />
113 <!-- Section headers (included in index)-->
114 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
121 <xsl:apply-templates mode="inline" />
124 <xsl:template match="naglowek_scena|naglowek_rozdzial">
130 <xsl:apply-templates mode="inline" />
133 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
138 <xsl:apply-templates mode="inline" />
141 <!-- Other paragraph tags -->
142 <xsl:template match="miejsce_czas">
148 <xsl:apply-templates mode="inline" />
151 <xsl:template match="didaskalia">
152 <xsl:variable name="content">
153 <xsl:apply-templates select="*|text()" mode="inline" />
157 / </xsl:text><xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" /><xsl:text> /</xsl:text>
160 <xsl:template match="lista_osoba">
163 <xsl:apply-templates mode="inline" />
166 <xsl:template match="akap|akap_dialog|akap_cd">
167 <xsl:variable name="content">
168 <xsl:apply-templates select="*|text()" mode="inline" />
173 <xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" />
176 <xsl:template match="strofa">
180 <xsl:when test="count(br) > 0">
181 <xsl:call-template name="verse">
182 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
183 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
185 <xsl:for-each select="br">
186 <!-- Each BR tag "consumes" text after it -->
187 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
188 <xsl:call-template name="verse">
189 <xsl:with-param name="verse-content"
190 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
191 <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]" />
196 <xsl:call-template name="verse">
197 <xsl:with-param name="verse-content" select="text() | node()" />
198 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
204 <xsl:template name="verse">
205 <xsl:param name="verse-content" />
206 <xsl:param name="verse-type" />
209 <xsl:variable name="content">
210 <xsl:apply-templates select="$verse-content" mode="inline" />
213 <xsl:when test="name($verse-type) = 'wers_akap'">
214 <xsl:text> </xsl:text>
216 <xsl:when test="name($verse-type) = 'wers_wciety'">
218 <xsl:when test="$verse-content/@typ">
219 <xsl:text> </xsl:text>
222 <xsl:text> </xsl:text>
226 <xsl:when test="name($verse-type) = 'wers_cd'">
227 <xsl:text> </xsl:text>
230 <xsl:value-of select="wl:strip($content)" />
233 <xsl:template match="motto_podpis">
234 <xsl:apply-templates mode="inline" />
237 <xsl:template match="tabela|tabelka">
241 <xsl:apply-templates/>
245 <xsl:template match="wiersz">
246 <xsl:apply-templates />
250 <xsl:template match="kol">
251 <xsl:apply-templates mode="inline" />
252 <xsl:text> </xsl:text>
256 <!-- ================================================ -->
257 <!-- = INLINE TAGS = -->
258 <!-- = (contain other inline tags and special tags) = -->
259 <!-- ================================================ -->
261 <xsl:template match="pa|pe|pr|pt" mode="inline" />
263 <!-- Other inline tags -->
264 <xsl:template match="mat" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
266 <xsl:template match="didask_tekst" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
268 <xsl:template match="slowo_obce" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
270 <xsl:template match="tytul_dziela" mode="inline">
271 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
274 <xsl:template match="wyroznienie" mode="inline">
275 <xsl:text>*</xsl:text><xsl:apply-templates mode="inline" /><xsl:text>*</xsl:text>
278 <xsl:template match="indeks_dolny" mode="inline">
279 <xsl:apply-templates mode="inline" />
282 <xsl:template match="osoba" mode="inline">
283 <xsl:apply-templates mode="inline" />
287 <!-- ============================================== -->
288 <!-- = STANDALONE TAGS = -->
289 <!-- = (cannot contain any other tags) = -->
290 <!-- ============================================== -->
291 <xsl:template match="sekcja_swiatlo">
299 <xsl:template match="sekcja_asterysk">
307 <xsl:template match="separator_linia">
310 ------------------------------------------------
316 <!-- ================ -->
317 <!-- = SPECIAL TAGS = -->
318 <!-- ================ -->
320 <xsl:template match="begin" mode="inline" />
322 <xsl:template match="end" mode="inline" />
324 <xsl:template match="begin|end" />
326 <xsl:template match="motyw" mode="inline" />
328 <xsl:template name="translators">
329 <xsl:if test="//dc:contributor.translator">
331 <xsl:for-each select="//dc:contributor.translator/text()">
332 <xsl:if test="position() != 1">
333 <xsl:text>, </xsl:text>
335 <xsl:value-of select="wl:person_name(.)" />
342 <xsl:template name="isbn">
343 <xsl:if test="//meta[@id='txt-id']">
344 <xsl:variable name="isbn" select="//meta[@id='txt-id']"/>
346 ISBN </text><xsl:value-of select="substring-after($isbn, 'ISBN-')"/>
351 <!-- ================ -->
352 <!-- = IGNORED TAGS = -->
353 <!-- ================ -->
354 <xsl:template match="extra|uwaga" />
355 <xsl:template match="extra|uwaga" mode="inline" />
357 <xsl:template match="nota_red" />
358 <xsl:template match="abstrakt" />
363 <xsl:template match="text()" />
364 <xsl:template match="text()" mode="inline">
365 <xsl:value-of select="wl:substitute_entities(.)" />