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" indent="yes" omit-xml-declaration = "yes" version="2.0" />
13 <xsl:strip-space elements="opowiadanie powiesc dramat_wierszowany_l dramat_wierszowany_lp dramat_wspolczesny liryka_l liryka_lp wywiad"/>
14 <xsl:template match="utwor">
16 <xsl:when test="@full-page">
19 <title>Książka z serwisu WolneLektury.pl</title>
20 <meta charset="utf-8" />
21 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
22 <link href="https://static.wolnelektury.pl/css/compressed/book_text.css" rel="stylesheet" type="text/css" />
25 <xsl:call-template name="book-text" />
30 <xsl:call-template name="book-text" />
35 <xsl:template name="book-text">
37 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
38 <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)])">
41 <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)]">
43 <xsl:attribute name="class">fn-<xsl:value-of select="name()" /></xsl:attribute>
44 <a name="{concat('footnote-', generate-id(.))}" />
45 <a href="{concat('#anchor-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
47 <xsl:when test="count(akap|akap_cd|strofa) = 0">
48 <p><xsl:apply-templates select="text()|*" mode="inline" />
49 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
53 <xsl:apply-templates select="text()|*" mode="inline" />
64 <!-- ============================================================================== -->
65 <!-- = MASTER TAG = -->
66 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
67 <!-- ============================================================================== -->
68 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
69 <xsl:apply-templates select="nota_red" mode="special" />
70 <xsl:if test="nazwa_utworu">
72 <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
73 <xsl:call-template name="translators" />
76 <xsl:apply-templates />
80 <!-- ==================================================================================== -->
81 <!-- = BLOCK TAGS = -->
82 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
83 <!-- ==================================================================================== -->
84 <xsl:template match="nota">
85 <div class="note"><xsl:apply-templates /></div>
88 <xsl:template match="lista_osob">
89 <div class="person-list">
90 <h3><xsl:value-of select="naglowek_listy" /></h3>
92 <xsl:apply-templates select="lista_osoba" />
97 <xsl:template match="dedykacja">
98 <div class="dedication"><xsl:apply-templates /></div>
101 <xsl:template match="kwestia">
102 <div class="kwestia">
103 <xsl:apply-templates select="strofa|akap|didaskalia" />
107 <xsl:template match="dlugi_cytat|poezja_cyt">
108 <blockquote><xsl:apply-templates /></blockquote>
111 <xsl:template match="motto">
112 <div class="motto"><xsl:apply-templates /></div>
116 <!-- ========================================== -->
117 <!-- = PARAGRAPH TAGS = -->
118 <!-- = (can contain inline and special tags) = -->
119 <!-- ========================================== -->
121 <xsl:template match="autor_utworu" mode="header">
122 <span class="author"><xsl:apply-templates mode="inline" /></span>
125 <xsl:template match="nazwa_utworu" mode="header">
126 <span class="title"><xsl:apply-templates mode="inline" /></span>
129 <xsl:template match="dzielo_nadrzedne" mode="header">
130 <span class="collection"><xsl:apply-templates mode="inline" /></span>
133 <xsl:template match="podtytul" mode="header">
134 <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
137 <!-- Section headers (included in index)-->
138 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
139 <xsl:call-template name="section-anchor"/>
140 <h2><xsl:apply-templates mode="inline" /></h2>
143 <xsl:template match="naglowek_scena|naglowek_rozdzial">
144 <xsl:call-template name="section-anchor"/>
145 <h3><xsl:apply-templates mode="inline" /></h3>
148 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
149 <xsl:call-template name="section-anchor"/>
150 <h4><xsl:apply-templates mode="inline" /></h4>
153 <!-- Other paragraph tags -->
154 <xsl:template match="miejsce_czas">
155 <xsl:call-template name="section-anchor"/>
156 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
159 <xsl:template match="didaskalia">
160 <xsl:call-template name="section-anchor"/>
161 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
164 <xsl:template match="lista_osoba">
165 <li><xsl:apply-templates mode="inline" /></li>
168 <xsl:template match="akap|akap_dialog|akap_cd">
169 <p class="paragraph">
170 <xsl:call-template name="section-anchor"/>
171 <xsl:apply-templates mode="inline" />
175 <xsl:template match="strofa">
177 <xsl:call-template name="section-anchor"/>
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]" />
204 <xsl:template name="verse">
205 <xsl:param name="verse-content" />
206 <xsl:param name="verse-type" />
209 <xsl:when test="name($verse-type) = 'wers_akap'">
210 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
212 <xsl:when test="name($verse-type) = 'wers_wciety'">
214 <xsl:when test="$verse-content/@typ">
215 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
218 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
222 <xsl:when test="name($verse-type) = 'wers_cd'">
223 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
226 <xsl:apply-templates select="$verse-content" mode="inline" />
230 <xsl:template match="motto_podpis">
231 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
235 <!-- ================================================ -->
236 <!-- = INLINE TAGS = -->
237 <!-- = (contain other inline tags and special tags) = -->
238 <!-- ================================================ -->
240 <xsl:template match="pa|pe|pr|pt" mode="inline">
241 <a name="{concat('anchor-', generate-id(.))}" />
242 <a href="{concat('#footnote-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
245 <!-- Other inline tags -->
246 <xsl:template match="mat" mode="inline">
247 <em class="math"><xsl:apply-templates mode="inline" /></em>
250 <xsl:template match="didask_tekst" mode="inline">
251 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
254 <xsl:template match="slowo_obce" mode="inline">
255 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
258 <xsl:template match="tytul_dziela" mode="inline">
259 <em class="book-title">
260 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
264 <xsl:template match="wyroznienie" mode="inline">
265 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
268 <xsl:template match="osoba" mode="inline">
269 <em class="person"><xsl:apply-templates mode="inline" /></em>
273 <!-- ============================================== -->
274 <!-- = STANDALONE TAGS = -->
275 <!-- = (cannot contain any other tags) = -->
276 <!-- ============================================== -->
277 <xsl:template match="sekcja_swiatlo">
278 <hr class="spacer" />
281 <xsl:template match="sekcja_asterysk">
282 <p class="spacer-asterisk">*</p>
285 <xsl:template match="separator_linia">
286 <hr class="spacer-line" />
290 <!-- ================ -->
291 <!-- = SPECIAL TAGS = -->
292 <!-- ================ -->
294 <xsl:template match="begin" mode="inline">
295 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
296 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
297 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
301 <xsl:template match="end" mode="inline">
302 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
305 <xsl:template match="begin|end">
306 <xsl:apply-templates select='.' mode="inline" />
309 <xsl:template match="motyw" mode="inline" />
312 <xsl:template match="nota_red" mode="special">
314 <xsl:apply-templates />
319 <xsl:template name="translators">
320 <xsl:if test="//dc:contributor.translator">
321 <span class="translator">
322 <xsl:text>tłum. </xsl:text>
323 <xsl:for-each select="//dc:contributor.translator">
324 <xsl:if test="position() != 1">, </xsl:if>
325 <xsl:apply-templates mode="person" />
331 <xsl:template match="text()" mode="person">
332 <xsl:value-of select="wl:person_name(.)" />
336 <!-- ================ -->
337 <!-- = IGNORED TAGS = -->
338 <!-- ================ -->
339 <xsl:template match="extra|uwaga" />
340 <xsl:template match="extra|uwaga" mode="inline" />
342 <xsl:template match="nota_red" />
347 <xsl:template match="text()" />
348 <xsl:template match="text()" mode="inline">
349 <xsl:value-of select="wl:substitute_entities(.)" />
355 <xsl:template name="section-anchor">
357 this formula works as follows:
358 - get all ancestors including self
359 - choose the header (third one from root): utwor/book-type/header
360 - get all preceding siblings
362 - create an <a name="sec123"/> tag.
364 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />