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="$gallery" /><xsl:value-of select="@src" />
140 <xsl:attribute name="alt">
141 <xsl:value-of select="@alt" />
143 <xsl:attribute name="title">
144 <xsl:value-of select="@alt" />
149 <xsl:template match="animacja">
150 <div class="animacja cycle-slideshow" data-cycle-pause-on-hover="true" data-cycle-next="> img" data-cycle-fx="fadeout" data-cycle-paused="true">
151 <xsl:apply-templates/>
156 <!-- ========================================== -->
157 <!-- = PARAGRAPH TAGS = -->
158 <!-- = (can contain inline and special tags) = -->
159 <!-- ========================================== -->
161 <xsl:template match="autor_utworu" mode="header">
162 <span class="author"><xsl:apply-templates mode="inline" /></span>
165 <xsl:template match="nazwa_utworu" mode="header">
166 <span class="title"><xsl:apply-templates mode="inline" /></span>
169 <xsl:template match="dzielo_nadrzedne" mode="header">
170 <span class="collection"><xsl:apply-templates mode="inline" /></span>
173 <xsl:template match="podtytul" mode="header">
174 <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
177 <!-- Section headers (included in index)-->
178 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
179 <xsl:call-template name="section-anchor"/>
180 <h2><xsl:apply-templates mode="inline" /></h2>
183 <xsl:template match="podtytul_akt|podtytul_czesc">
184 <div class="subtitle2">
185 <xsl:apply-templates mode="inline" />
189 <xsl:template match="naglowek_scena|naglowek_rozdzial">
190 <xsl:call-template name="section-anchor"/>
191 <h3><xsl:apply-templates mode="inline" /></h3>
194 <xsl:template match="podtytul_scena|podtytul_rozdzial">
195 <div class="subtitle3">
196 <xsl:apply-templates mode="inline" />
200 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
201 <xsl:call-template name="section-anchor"/>
202 <h4><xsl:apply-templates mode="inline" /></h4>
205 <xsl:template match="podtytul_podrozdzial">
206 <div class="subtitle4">
207 <xsl:apply-templates mode="inline" />
211 <!-- Other paragraph tags -->
212 <xsl:template match="miejsce_czas">
213 <xsl:call-template name="section-anchor"/>
214 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
217 <xsl:template match="didaskalia">
218 <xsl:call-template name="section-anchor"/>
219 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
222 <xsl:template match="lista_osoba">
223 <li><xsl:apply-templates mode="inline" /></li>
226 <xsl:template match="akap|akap_dialog|akap_cd">
227 <p class="paragraph">
228 <xsl:call-template name="section-anchor"/>
229 <xsl:apply-templates mode="inline" />
233 <xsl:template match="strofa" mode="inline">
234 <xsl:apply-templates select="." />
237 <xsl:template match="strofa">
239 <xsl:call-template name="section-anchor"/>
241 <xsl:when test="count(br) > 0">
242 <xsl:call-template name="verse">
243 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
244 <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]" />
246 <xsl:for-each select="br">
247 <!-- Each BR tag "consumes" text after it -->
248 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
249 <xsl:call-template name="verse">
250 <xsl:with-param name="verse-content"
251 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
252 <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]" />
257 <xsl:call-template name="verse">
258 <xsl:with-param name="verse-content" select="text() | node()" />
259 <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:when test="name($verse-type) = 'wers_akap'">
272 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
274 <xsl:when test="name($verse-type) = 'wers_wciety'">
276 <xsl:when test="$verse-content/@typ">
277 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
280 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
284 <xsl:when test="name($verse-type) = 'wers_cd'">
285 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
287 <xsl:when test="name($verse-type) = 'wers_do_prawej'">
288 <xsl:attribute name="style">text-align: right</xsl:attribute>
291 <xsl:apply-templates select="$verse-content" mode="inline" />
295 <xsl:template match="motto_podpis">
296 <xsl:call-template name="section-anchor"/>
297 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
300 <xsl:template match="tabela|tabelka">
301 <xsl:call-template name="section-anchor"/>
303 <xsl:when test="@ramka = '1'">
304 <table class="border"><xsl:apply-templates /></table>
307 <table><xsl:apply-templates /></table>
311 <xsl:template match="wiersz">
312 <tr><xsl:apply-templates /></tr>
314 <xsl:template match="kol">
315 <td><xsl:apply-templates mode="inline" /></td>
318 <xsl:template match="mat">
319 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
323 <!-- ================================================ -->
324 <!-- = INLINE TAGS = -->
325 <!-- = (contain other inline tags and special tags) = -->
326 <!-- ================================================ -->
328 <xsl:template match="pa|pe|pr|pt" mode="inline">
329 <a name="{concat('anchor-', generate-id(.))}" />
330 <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>
333 <xsl:template match="ref" mode="inline">
334 <a class="reference" data-uri="">
335 <xsl:attribute name="data-uri">
336 <xsl:value-of select="@href"/>
341 <!-- Other inline tags -->
342 <xsl:template match="mat" mode="inline">
343 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
346 <xsl:template match="didask_tekst" mode="inline">
347 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
350 <xsl:template match="slowo_obce" mode="inline">
351 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
354 <xsl:template match="tytul_dziela" mode="inline">
355 <em class="book-title">
356 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
360 <xsl:template match="wyroznienie" mode="inline">
361 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
364 <xsl:template match="wieksze_odstepy" mode="inline">
365 <em class="wieksze-odstepy"><xsl:apply-templates mode="inline" /></em>
368 <xsl:template match="indeks_dolny" mode="inline">
369 <sub><xsl:apply-templates mode="inline" /></sub>
372 <xsl:template match="osoba" mode="inline">
373 <em class="person"><xsl:apply-templates mode="inline" /></em>
377 <!-- ============================================== -->
378 <!-- = STANDALONE TAGS = -->
379 <!-- = (cannot contain any other tags) = -->
380 <!-- ============================================== -->
381 <xsl:template match="sekcja_swiatlo">
382 <hr class="spacer" />
385 <xsl:template match="sekcja_asterysk">
386 <p class="spacer-asterisk">*</p>
389 <xsl:template match="separator_linia">
390 <hr class="spacer-line" />
394 <!-- ================ -->
395 <!-- = SPECIAL TAGS = -->
396 <!-- ================ -->
398 <xsl:template match="begin" mode="inline">
399 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
400 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
401 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
405 <xsl:template match="end" mode="inline">
406 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
409 <xsl:template match="begin|end">
410 <xsl:apply-templates select='.' mode="inline" />
413 <xsl:template match="motyw" mode="inline" />
416 <xsl:template match="nota_red" mode="special">
418 <xsl:apply-templates />
423 <xsl:template name="translators">
424 <xsl:if test="//dc:contributor.translator">
425 <span class="translator">
426 <xsl:text>tłum. </xsl:text>
427 <xsl:for-each select="//dc:contributor.translator">
428 <xsl:if test="position() != 1">, </xsl:if>
429 <xsl:apply-templates mode="person" />
435 <xsl:template match="text()" mode="person">
436 <xsl:value-of select="wl:person_name(.)" />
440 <!-- ================ -->
441 <!-- = IGNORED TAGS = -->
442 <!-- ================ -->
443 <xsl:template match="extra|uwaga" />
444 <xsl:template match="extra|uwaga" mode="inline" />
446 <xsl:template match="nota_red" />
447 <xsl:template match="abstrakt" />
452 <xsl:template match="text()" />
453 <xsl:template match="text()" mode="inline">
454 <xsl:value-of select="wl:substitute_entities(.)" />
460 <xsl:template name="section-anchor">
462 this formula works as follows:
463 - get all ancestors including self
464 - choose the header (third one from root): utwor/book-type/header
465 - get all preceding siblings
467 - create an <a name="sec123"/> tag.
469 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />