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 Wolne Lektury. 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="ramka">
44 <xsl:apply-templates />
47 <xsl:template match="lista_osob">
52 <xsl:value-of select="naglowek_listy" />
53 <xsl:apply-templates select="lista_osoba" />
58 <xsl:template match="dedykacja">
62 <xsl:apply-templates />
65 <xsl:template match="kwestia">
66 <xsl:apply-templates select="strofa|akap|didaskalia" />
69 <xsl:template match="dlugi_cytat|poezja_cyt">
72 <xsl:apply-templates />
75 <xsl:template match="motto">
81 <xsl:apply-templates /><xsl:text>
87 <!-- ========================================== -->
88 <!-- = PARAGRAPH TAGS = -->
89 <!-- = (can contain inline and special tags) = -->
90 <!-- ========================================== -->
92 <xsl:template match="autor_utworu" mode="header">
93 <xsl:apply-templates mode="inline" />
99 <xsl:template match="nazwa_utworu" mode="header">
100 <xsl:apply-templates mode="inline" />
105 <xsl:template match="dzielo_nadrzedne" mode="header">
106 <xsl:apply-templates mode="inline" />
111 <xsl:template match="podtytul" mode="header">
112 <xsl:apply-templates mode="inline" />
117 <!-- Section headers (included in index)-->
118 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
125 <xsl:apply-templates mode="inline" />
128 <xsl:template match="naglowek_scena|naglowek_rozdzial">
134 <xsl:apply-templates mode="inline" />
137 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
142 <xsl:apply-templates mode="inline" />
146 <xsl:template match="podtytul_czesc|podtytul_rozdzial|podtytul_podrozdzial|podtytul_akt|podtytul_scena">
150 <xsl:apply-templates mode="inline" />
155 <!-- Other paragraph tags -->
156 <xsl:template match="miejsce_czas">
162 <xsl:apply-templates mode="inline" />
165 <xsl:template match="didaskalia">
166 <xsl:variable name="content">
167 <xsl:apply-templates select="*|text()" mode="inline" />
171 / </xsl:text><xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" /><xsl:text> /</xsl:text>
174 <xsl:template match="lista_osoba">
177 <xsl:apply-templates mode="inline" />
180 <xsl:template match="akap|akap_dialog|akap_cd|werset">
181 <xsl:variable name="content">
182 <xsl:apply-templates select="*|text()" mode="inline" />
187 <xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" />
190 <xsl:template match="list">
195 <xsl:apply-templates />
201 <xsl:template match="adesat">
204 <xsl:apply-templates select="*|text()" mode="inline" />
208 <xsl:template match="miejsce_data">
211 <xsl:apply-templates select="*|text()" mode="inline" />
215 <xsl:template match="naglowek_listu">
219 <xsl:apply-templates select="*|text()" mode="inline" />
223 <xsl:template match="pozdrowienie">
226 <xsl:apply-templates select="*|text()" mode="inline" />
230 <xsl:template match="podpis">
233 <xsl:apply-templates select="*|text()" mode="inline" />
238 <xsl:template match="strofa">
242 <xsl:when test="count(br) > 0">
243 <xsl:call-template name="verse">
244 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
245 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd' or name() = 'wers_do_prawej'][1]" />
247 <xsl:for-each select="br">
248 <!-- Each BR tag "consumes" text after it -->
249 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
250 <xsl:call-template name="verse">
251 <xsl:with-param name="verse-content"
252 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
253 <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' or name() = 'wers_do_prawej')][1]" />
258 <xsl:call-template name="verse">
259 <xsl:with-param name="verse-content" select="text() | node()" />
260 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
266 <xsl:template name="verse">
267 <xsl:param name="verse-content" />
268 <xsl:param name="verse-type" />
271 <xsl:variable name="content">
272 <xsl:apply-templates select="$verse-content" mode="inline" />
275 <xsl:when test="name($verse-type) = 'wers_akap'">
276 <xsl:text> </xsl:text>
278 <xsl:when test="name($verse-type) = 'wers_wciety'">
280 <xsl:when test="$verse-content/@typ">
281 <xsl:text> </xsl:text>
284 <xsl:text> </xsl:text>
288 <xsl:when test="name($verse-type) = 'wers_cd'">
289 <xsl:text> </xsl:text>
291 <xsl:when test="name($verse-type) = 'wers_do_prawej'">
292 <xsl:text> </xsl:text>
295 <xsl:value-of select="wl:strip($content)" />
298 <xsl:template match="motto_podpis">
299 <xsl:apply-templates mode="inline" />
302 <xsl:template match="tabela|tabelka">
306 <xsl:apply-templates/>
310 <xsl:template match="wiersz">
311 <xsl:apply-templates />
315 <xsl:template match="kol">
316 <xsl:apply-templates mode="inline" />
317 <xsl:text> </xsl:text>
321 <!-- ================================================ -->
322 <!-- = INLINE TAGS = -->
323 <!-- = (contain other inline tags and special tags) = -->
324 <!-- ================================================ -->
326 <xsl:template match="pa|pe|pr|pt|ptrad" mode="inline" />
328 <!-- Other inline tags -->
329 <xsl:template match="mat" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
331 <xsl:template match="didask_tekst" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
333 <xsl:template match="slowo_obce" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
335 <xsl:template match="tytul_dziela" mode="inline">
336 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
339 <xsl:template match="wyroznienie" mode="inline">
340 <xsl:text>*</xsl:text><xsl:apply-templates mode="inline" /><xsl:text>*</xsl:text>
343 <xsl:template match="indeks_dolny" mode="inline">
344 <xsl:apply-templates mode="inline" />
347 <xsl:template match="wieksze_odstepy" mode="inline">
348 <xsl:apply-templates mode="inline" />
351 <xsl:template match="osoba" mode="inline">
352 <xsl:apply-templates mode="inline" />
356 <!-- ============================================== -->
357 <!-- = STANDALONE TAGS = -->
358 <!-- = (cannot contain any other tags) = -->
359 <!-- ============================================== -->
360 <xsl:template match="sekcja_swiatlo">
368 <xsl:template match="sekcja_asterysk">
376 <xsl:template match="separator_linia">
379 ------------------------------------------------
385 <!-- ================ -->
386 <!-- = SPECIAL TAGS = -->
387 <!-- ================ -->
389 <xsl:template match="begin" mode="inline" />
391 <xsl:template match="end" mode="inline" />
393 <xsl:template match="begin|end" />
395 <xsl:template match="motyw" mode="inline" />
397 <xsl:template name="translators">
398 <xsl:if test="//dc:contributor.translator">
400 <xsl:for-each select="//dc:contributor.translator/text()">
401 <xsl:if test="position() != 1">
402 <xsl:text>, </xsl:text>
404 <xsl:value-of select="wl:person_name(.)" />
411 <xsl:template name="isbn">
412 <xsl:if test="//meta[@id='txt-id']">
413 <xsl:variable name="isbn" select="//meta[@id='txt-id']"/>
415 ISBN </text><xsl:value-of select="substring-after($isbn, 'ISBN-')"/>
420 <!-- ================ -->
421 <!-- = IGNORED TAGS = -->
422 <!-- ================ -->
423 <xsl:template match="extra|uwaga" />
424 <xsl:template match="extra|uwaga" mode="inline" />
426 <xsl:template match="nota_red" />
427 <xsl:template match="abstrakt" />
432 <xsl:template match="text()" />
433 <xsl:template match="text()" mode="inline">
434 <xsl:value-of select="wl:substitute_entities(.)" />