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 rel="stylesheet" type="text/css">
23 <xsl:attribute name="href">
24 <xsl:value-of select="$css" />
29 <xsl:call-template name="book-text" />
31 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
32 <script src="http://malsup.github.io/min/jquery.cycle2.min.js"></script>
37 <xsl:call-template name="book-text" />
42 <xsl:template name="book-text">
44 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
45 <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)])">
48 <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)]">
50 <xsl:attribute name="class">fn-<xsl:value-of select="name()" /></xsl:attribute>
51 <a name="{concat('footnote-', generate-id(.))}" />
52 <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>
54 <xsl:when test="count(akap|akap_cd|strofa) = 0">
55 <p><xsl:apply-templates select="text()|*" mode="inline" />
56 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
57 <xsl:if test="name()='pt'"> [przypis tłumacza]</xsl:if>
58 <xsl:if test="name()='pr'"> [przypis redakcyjny]</xsl:if>
59 <xsl:if test="name()='pe'"> [przypis edytorski]</xsl:if>
63 <xsl:apply-templates select="text()|*" mode="inline" />
74 <!-- ============================================================================== -->
75 <!-- = MASTER TAG = -->
76 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
77 <!-- ============================================================================== -->
78 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
79 <xsl:apply-templates select="nota_red" mode="special" />
80 <xsl:if test="nazwa_utworu">
82 <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
83 <xsl:call-template name="translators" />
86 <xsl:apply-templates />
90 <!-- ==================================================================================== -->
91 <!-- = BLOCK TAGS = -->
92 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
93 <!-- ==================================================================================== -->
94 <xsl:template match="nota">
95 <div class="note"><xsl:apply-templates /></div>
98 <xsl:template match="lista_osob">
99 <xsl:call-template name="section-anchor"/>
100 <div class="person-list">
101 <h3><xsl:value-of select="naglowek_listy" /></h3>
103 <xsl:apply-templates select="lista_osoba" />
108 <xsl:template match="dedykacja">
109 <div class="dedication"><xsl:apply-templates /></div>
112 <xsl:template match="ramka">
113 <div class="frame"><xsl:apply-templates /></div>
116 <xsl:template match="kwestia">
117 <div class="kwestia">
118 <xsl:apply-templates select="strofa|akap|didaskalia" />
122 <xsl:template match="dlugi_cytat|poezja_cyt">
123 <blockquote><xsl:apply-templates /></blockquote>
126 <xsl:template match="motto">
127 <xsl:call-template name="section-anchor"/>
128 <div class="motto"><xsl:apply-templates /></div>
131 <xsl:template match="ilustr" mode="inline">
132 <xsl:apply-templates select="."/>
135 <xsl:template match="ilustr">
137 <xsl:attribute name="src">
138 <xsl:value-of select="@src" />
140 <xsl:attribute name="srcset">
141 <xsl:value-of select="@srcset" />
143 <xsl:attribute name="sizes">
144 (min-width: 718px) 600px,
145 (min-width: 600px) calc(100vw - 118px),
146 (min-width: 320px) calc(100vw - 75px),
147 (min-width: 15em) calc(100wv - 60px),
150 <xsl:attribute name="alt">
151 <xsl:value-of select="@alt" />
153 <xsl:attribute name="title">
154 <xsl:value-of select="@alt" />
159 <xsl:template match="animacja">
160 <div class="animacja cycle-slideshow" data-cycle-pause-on-hover="true" data-cycle-next="> img" data-cycle-fx="fadeout" data-cycle-paused="true">
161 <xsl:apply-templates/>
166 <!-- ========================================== -->
167 <!-- = PARAGRAPH TAGS = -->
168 <!-- = (can contain inline and special tags) = -->
169 <!-- ========================================== -->
171 <xsl:template match="autor_utworu" mode="header">
172 <span class="author"><xsl:apply-templates mode="inline" /></span>
175 <xsl:template match="nazwa_utworu" mode="header">
176 <span class="title"><xsl:apply-templates mode="inline" /></span>
179 <xsl:template match="dzielo_nadrzedne" mode="header">
180 <span class="collection"><xsl:apply-templates mode="inline" /></span>
183 <xsl:template match="podtytul" mode="header">
184 <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
187 <!-- Section headers (included in index)-->
188 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
189 <xsl:call-template name="section-anchor"/>
190 <h2><xsl:apply-templates mode="inline" /></h2>
193 <xsl:template match="podtytul_akt|podtytul_czesc">
194 <div class="subtitle2">
195 <xsl:apply-templates mode="inline" />
199 <xsl:template match="naglowek_scena|naglowek_rozdzial">
200 <xsl:call-template name="section-anchor"/>
201 <h3><xsl:apply-templates mode="inline" /></h3>
204 <xsl:template match="podtytul_scena|podtytul_rozdzial">
205 <div class="subtitle3">
206 <xsl:apply-templates mode="inline" />
210 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
211 <xsl:call-template name="section-anchor"/>
212 <h4><xsl:apply-templates mode="inline" /></h4>
215 <xsl:template match="podtytul_podrozdzial">
216 <div class="subtitle4">
217 <xsl:apply-templates mode="inline" />
221 <!-- Other paragraph tags -->
222 <xsl:template match="miejsce_czas">
223 <xsl:call-template name="section-anchor"/>
224 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
227 <xsl:template match="didaskalia">
228 <xsl:call-template name="section-anchor"/>
229 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
232 <xsl:template match="lista_osoba">
233 <li><xsl:apply-templates mode="inline" /></li>
236 <xsl:template match="akap|akap_dialog|akap_cd">
237 <p class="paragraph">
238 <xsl:call-template name="section-anchor"/>
239 <xsl:apply-templates mode="inline" />
243 <xsl:template match="strofa" mode="inline">
244 <xsl:apply-templates select="." />
247 <xsl:template match="strofa">
249 <xsl:call-template name="section-anchor"/>
251 <xsl:when test="count(br) > 0">
252 <xsl:call-template name="verse">
253 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
254 <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]" />
256 <xsl:for-each select="br">
257 <!-- Each BR tag "consumes" text after it -->
258 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
259 <xsl:call-template name="verse">
260 <xsl:with-param name="verse-content"
261 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
262 <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]" />
267 <xsl:call-template name="verse">
268 <xsl:with-param name="verse-content" select="text() | node()" />
269 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
276 <xsl:template name="verse">
277 <xsl:param name="verse-content" />
278 <xsl:param name="verse-type" />
281 <xsl:when test="name($verse-type) = 'wers_akap'">
282 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
284 <xsl:when test="name($verse-type) = 'wers_wciety'">
286 <xsl:when test="$verse-content/@typ">
287 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
290 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
294 <xsl:when test="name($verse-type) = 'wers_cd'">
295 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
297 <xsl:when test="name($verse-type) = 'wers_do_prawej'">
298 <xsl:attribute name="style">text-align: right</xsl:attribute>
301 <xsl:apply-templates select="$verse-content" mode="inline" />
305 <xsl:template match="motto_podpis">
306 <xsl:call-template name="section-anchor"/>
307 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
310 <xsl:template match="tabela|tabelka">
311 <xsl:call-template name="section-anchor"/>
313 <xsl:when test="@ramka = '1'">
314 <table class="border"><xsl:apply-templates /></table>
317 <table><xsl:apply-templates /></table>
321 <xsl:template match="wiersz">
322 <tr><xsl:apply-templates /></tr>
324 <xsl:template match="kol">
325 <td><xsl:apply-templates mode="inline" /></td>
328 <xsl:template match="mat">
329 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
333 <!-- ================================================ -->
334 <!-- = INLINE TAGS = -->
335 <!-- = (contain other inline tags and special tags) = -->
336 <!-- ================================================ -->
338 <xsl:template match="pa|pe|pr|pt" mode="inline">
339 <a name="{concat('anchor-', generate-id(.))}" />
340 <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>
343 <xsl:template match="ref" mode="inline">
344 <a class="reference" data-uri="">
345 <xsl:attribute name="data-uri">
346 <xsl:value-of select="@href"/>
351 <!-- Other inline tags -->
352 <xsl:template match="mat" mode="inline">
353 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
356 <xsl:template match="didask_tekst" mode="inline">
357 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
360 <xsl:template match="slowo_obce" mode="inline">
361 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
364 <xsl:template match="tytul_dziela" mode="inline">
365 <em class="book-title">
366 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
370 <xsl:template match="wyroznienie" mode="inline">
371 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
374 <xsl:template match="wieksze_odstepy" mode="inline">
375 <em class="wieksze-odstepy"><xsl:apply-templates mode="inline" /></em>
378 <xsl:template match="indeks_dolny" mode="inline">
379 <sub><xsl:apply-templates mode="inline" /></sub>
382 <xsl:template match="osoba" mode="inline">
383 <em class="person"><xsl:apply-templates mode="inline" /></em>
387 <!-- ============================================== -->
388 <!-- = STANDALONE TAGS = -->
389 <!-- = (cannot contain any other tags) = -->
390 <!-- ============================================== -->
391 <xsl:template match="sekcja_swiatlo">
392 <hr class="spacer" />
395 <xsl:template match="sekcja_asterysk">
396 <p class="spacer-asterisk">*</p>
399 <xsl:template match="separator_linia">
400 <hr class="spacer-line" />
404 <!-- ================ -->
405 <!-- = SPECIAL TAGS = -->
406 <!-- ================ -->
408 <xsl:template match="begin" mode="inline">
409 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
410 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
411 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
415 <xsl:template match="end" mode="inline">
416 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
419 <xsl:template match="begin|end">
420 <xsl:apply-templates select='.' mode="inline" />
423 <xsl:template match="motyw" mode="inline" />
426 <xsl:template match="nota_red" mode="special">
428 <xsl:apply-templates />
433 <xsl:template name="translators">
434 <xsl:if test="//dc:contributor.translator">
435 <span class="translator">
436 <xsl:text>tłum. </xsl:text>
437 <xsl:for-each select="//dc:contributor.translator">
438 <xsl:if test="position() != 1">, </xsl:if>
439 <xsl:apply-templates mode="person" />
445 <xsl:template match="text()" mode="person">
446 <xsl:value-of select="wl:person_name(.)" />
450 <!-- ================ -->
451 <!-- = IGNORED TAGS = -->
452 <!-- ================ -->
453 <xsl:template match="extra|uwaga" />
454 <xsl:template match="extra|uwaga" mode="inline" />
456 <xsl:template match="nota_red" />
457 <xsl:template match="abstrakt" />
462 <xsl:template match="text()" />
463 <xsl:template match="text()" mode="inline">
464 <xsl:value-of select="wl:substitute_entities(.)" />
470 <xsl:template name="section-anchor">
472 this formula works as follows:
473 - get all ancestors including self
474 - choose the header (third one from root): utwor/book-type/header
475 - get all preceding siblings
477 - create an <a name="sec123"/> tag.
479 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />