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="naglowek_scena|naglowek_rozdzial">
184 <xsl:call-template name="section-anchor"/>
185 <h3><xsl:apply-templates mode="inline" /></h3>
188 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
189 <xsl:call-template name="section-anchor"/>
190 <h4><xsl:apply-templates mode="inline" /></h4>
193 <!-- Other paragraph tags -->
194 <xsl:template match="miejsce_czas">
195 <xsl:call-template name="section-anchor"/>
196 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
199 <xsl:template match="didaskalia">
200 <xsl:call-template name="section-anchor"/>
201 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
204 <xsl:template match="lista_osoba">
205 <li><xsl:apply-templates mode="inline" /></li>
208 <xsl:template match="akap|akap_dialog|akap_cd">
209 <p class="paragraph">
210 <xsl:call-template name="section-anchor"/>
211 <xsl:apply-templates mode="inline" />
215 <xsl:template match="strofa" mode="inline">
216 <xsl:apply-templates select="." />
219 <xsl:template match="strofa">
221 <xsl:call-template name="section-anchor"/>
223 <xsl:when test="count(br) > 0">
224 <xsl:call-template name="verse">
225 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
226 <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]" />
228 <xsl:for-each select="br">
229 <!-- Each BR tag "consumes" text after it -->
230 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
231 <xsl:call-template name="verse">
232 <xsl:with-param name="verse-content"
233 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
234 <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]" />
239 <xsl:call-template name="verse">
240 <xsl:with-param name="verse-content" select="text() | node()" />
241 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
248 <xsl:template name="verse">
249 <xsl:param name="verse-content" />
250 <xsl:param name="verse-type" />
253 <xsl:when test="name($verse-type) = 'wers_akap'">
254 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
256 <xsl:when test="name($verse-type) = 'wers_wciety'">
258 <xsl:when test="$verse-content/@typ">
259 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
262 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
266 <xsl:when test="name($verse-type) = 'wers_cd'">
267 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
269 <xsl:when test="name($verse-type) = 'wers_do_prawej'">
270 <xsl:attribute name="style">text-align: right</xsl:attribute>
273 <xsl:apply-templates select="$verse-content" mode="inline" />
277 <xsl:template match="motto_podpis">
278 <xsl:call-template name="section-anchor"/>
279 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
282 <xsl:template match="tabela|tabelka">
283 <xsl:call-template name="section-anchor"/>
285 <xsl:when test="@ramka = '1'">
286 <table class="border"><xsl:apply-templates /></table>
289 <table><xsl:apply-templates /></table>
293 <xsl:template match="wiersz">
294 <tr><xsl:apply-templates /></tr>
296 <xsl:template match="kol">
297 <td><xsl:apply-templates mode="inline" /></td>
300 <xsl:template match="mat">
301 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
305 <!-- ================================================ -->
306 <!-- = INLINE TAGS = -->
307 <!-- = (contain other inline tags and special tags) = -->
308 <!-- ================================================ -->
310 <xsl:template match="pa|pe|pr|pt" mode="inline">
311 <a name="{concat('anchor-', generate-id(.))}" />
312 <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>
315 <!-- Other inline tags -->
316 <xsl:template match="mat" mode="inline">
317 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
320 <xsl:template match="didask_tekst" mode="inline">
321 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
324 <xsl:template match="slowo_obce" mode="inline">
325 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
328 <xsl:template match="tytul_dziela" mode="inline">
329 <em class="book-title">
330 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
334 <xsl:template match="wyroznienie" mode="inline">
335 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
338 <xsl:template match="wieksze_odstepy" mode="inline">
339 <em class="wieksze-odstepy"><xsl:apply-templates mode="inline" /></em>
342 <xsl:template match="indeks_dolny" mode="inline">
343 <sub><xsl:apply-templates mode="inline" /></sub>
346 <xsl:template match="osoba" mode="inline">
347 <em class="person"><xsl:apply-templates mode="inline" /></em>
351 <!-- ============================================== -->
352 <!-- = STANDALONE TAGS = -->
353 <!-- = (cannot contain any other tags) = -->
354 <!-- ============================================== -->
355 <xsl:template match="sekcja_swiatlo">
356 <hr class="spacer" />
359 <xsl:template match="sekcja_asterysk">
360 <p class="spacer-asterisk">*</p>
363 <xsl:template match="separator_linia">
364 <hr class="spacer-line" />
368 <!-- ================ -->
369 <!-- = SPECIAL TAGS = -->
370 <!-- ================ -->
372 <xsl:template match="begin" mode="inline">
373 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
374 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
375 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
379 <xsl:template match="end" mode="inline">
380 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
383 <xsl:template match="begin|end">
384 <xsl:apply-templates select='.' mode="inline" />
387 <xsl:template match="motyw" mode="inline" />
390 <xsl:template match="nota_red" mode="special">
392 <xsl:apply-templates />
397 <xsl:template name="translators">
398 <xsl:if test="//dc:contributor.translator">
399 <span class="translator">
400 <xsl:text>tłum. </xsl:text>
401 <xsl:for-each select="//dc:contributor.translator">
402 <xsl:if test="position() != 1">, </xsl:if>
403 <xsl:apply-templates mode="person" />
409 <xsl:template match="text()" mode="person">
410 <xsl:value-of select="wl:person_name(.)" />
414 <!-- ================ -->
415 <!-- = IGNORED TAGS = -->
416 <!-- ================ -->
417 <xsl:template match="extra|uwaga" />
418 <xsl:template match="extra|uwaga" mode="inline" />
420 <xsl:template match="nota_red" />
421 <xsl:template match="abstrakt" />
426 <xsl:template match="text()" />
427 <xsl:template match="text()" mode="inline">
428 <xsl:value-of select="wl:substitute_entities(.)" />
434 <xsl:template name="section-anchor">
436 this formula works as follows:
437 - get all ancestors including self
438 - choose the header (third one from root): utwor/book-type/header
439 - get all preceding siblings
441 - create an <a name="sec123"/> tag.
443 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />