1 <?xml version="1.0" encoding="utf-8"?>
4 # This file is part of Librarian.
6 # Copyright © 2008,2009,2010 Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>
8 # For full list of contributors see AUTHORS file.
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU Affero General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Affero General Public License for more details.
20 # You should have received a copy of the GNU Affero General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
25 xmlns:wl="http://wolnelektury.pl/functions" >
27 <xsl:output encoding="utf-8" method="text" />
29 <xsl:param name="wrapping" select="0" />
31 <!-- ============================================================================== -->
32 <!-- = MASTER TAG = -->
33 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
34 <!-- ============================================================================== -->
35 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
36 <xsl:if test="nazwa_utworu"><xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" /></xsl:if>
40 <xsl:apply-templates />
44 <!-- ==================================================================================== -->
45 <!-- = BLOCK TAGS = -->
46 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
47 <!-- ==================================================================================== -->
48 <xsl:template match="nota">
49 <xsl:apply-templates />
52 <xsl:template match="lista_osob">
57 <xsl:value-of select="naglowek_listy" />
58 <xsl:apply-templates select="lista_osoba" />
63 <xsl:template match="dedykacja">
67 <xsl:apply-templates />
70 <xsl:template match="kwestia">
71 <xsl:apply-templates select="strofa|akap|didaskalia" />
74 <xsl:template match="dlugi_cytat|poezja_cyt">
77 <xsl:apply-templates />
80 <xsl:template match="motto">
86 <xsl:apply-templates /><xsl:text>
92 <!-- ========================================== -->
93 <!-- = PARAGRAPH TAGS = -->
94 <!-- = (can contain inline and special tags) = -->
95 <!-- ========================================== -->
97 <xsl:template match="autor_utworu" mode="header">
101 <xsl:apply-templates mode="inline" />
104 <xsl:template match="nazwa_utworu" mode="header">
108 <xsl:apply-templates mode="inline" />
111 <xsl:template match="dzielo_nadrzedne" mode="header">
115 <xsl:apply-templates mode="inline" />
118 <xsl:template match="podtytul" mode="header">
121 <xsl:apply-templates mode="inline" />
124 <!-- Section headers (included in index)-->
125 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
132 <xsl:apply-templates mode="inline" />
135 <xsl:template match="naglowek_scena|naglowek_rozdzial">
141 <xsl:apply-templates mode="inline" />
144 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
149 <xsl:apply-templates mode="inline" />
152 <!-- Other paragraph tags -->
153 <xsl:template match="miejsce_czas">
159 <xsl:apply-templates mode="inline" />
162 <xsl:template match="didaskalia">
163 <xsl:variable name="content">
164 <xsl:apply-templates select="*|text()" mode="inline" />
168 / </xsl:text><xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" /><xsl:text> /</xsl:text>
171 <xsl:template match="lista_osoba">
174 <xsl:apply-templates mode="inline" />
177 <xsl:template match="akap|akap_dialog|akap_cd">
178 <xsl:variable name="content">
179 <xsl:apply-templates select="*|text()" mode="inline" />
184 <xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" />
187 <xsl:template match="strofa">
191 <xsl:when test="count(br) > 0">
192 <xsl:call-template name="verse">
193 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
194 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
196 <xsl:for-each select="br">
197 <!-- Each BR tag "consumes" text after it -->
198 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
199 <xsl:call-template name="verse">
200 <xsl:with-param name="verse-content"
201 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
202 <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]" />
207 <xsl:call-template name="verse">
208 <xsl:with-param name="verse-content" select="text() | node()" />
209 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
215 <xsl:template name="verse">
216 <xsl:param name="verse-content" />
217 <xsl:param name="verse-type" />
220 <xsl:variable name="content">
221 <xsl:apply-templates select="$verse-content" mode="inline" />
224 <xsl:when test="name($verse-type) = 'wers_akap'">
225 <xsl:text> </xsl:text>
227 <xsl:when test="name($verse-type) = 'wers_wciety'">
229 <xsl:when test="$verse-content/@typ">
230 <xsl:text> </xsl:text>
233 <xsl:text> </xsl:text>
237 <xsl:when test="name($verse-type) = 'wers_cd'">
238 <xsl:text> </xsl:text>
241 <xsl:value-of select="wl:strip($content)" />
244 <xsl:template match="motto_podpis">
245 <xsl:apply-templates mode="inline" />
249 <!-- ================================================ -->
250 <!-- = INLINE TAGS = -->
251 <!-- = (contain other inline tags and special tags) = -->
252 <!-- ================================================ -->
254 <xsl:template match="pa|pe|pr|pt" mode="inline" />
256 <!-- Other inline tags -->
257 <xsl:template match="mat" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
259 <xsl:template match="didask_tekst" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
261 <xsl:template match="slowo_obce" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
263 <xsl:template match="tytul_dziela" mode="inline">
264 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
267 <xsl:template match="wyroznienie" mode="inline">
268 <xsl:text>*</xsl:text><xsl:apply-templates mode="inline" /><xsl:text>*</xsl:text>
271 <xsl:template match="osoba" mode="inline">
272 <xsl:apply-templates mode="inline" />
276 <!-- ============================================== -->
277 <!-- = STANDALONE TAGS = -->
278 <!-- = (cannot contain any other tags) = -->
279 <!-- ============================================== -->
280 <xsl:template match="sekcja_swiatlo">
288 <xsl:template match="sekcja_asterysk">
296 <xsl:template match="separator_linia">
299 ------------------------------------------------
305 <!-- ================ -->
306 <!-- = SPECIAL TAGS = -->
307 <!-- ================ -->
309 <xsl:template match="begin" mode="inline" />
311 <xsl:template match="end" mode="inline" />
313 <xsl:template match="begin|end" />
315 <xsl:template match="motyw" mode="inline" />
318 <!-- ================ -->
319 <!-- = IGNORED TAGS = -->
320 <!-- ================ -->
321 <xsl:template match="extra|uwaga" />
322 <xsl:template match="extra|uwaga" mode="inline" />
328 <xsl:template match="text()" />
329 <xsl:template match="text()" mode="inline">
330 <xsl:value-of select="wl:substitute_entities(.)" />