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>
115 <xsl:template match="ilustr" mode="inline">
116 <xsl:apply-templates select="."/>
119 <xsl:template match="ilustr">
121 <xsl:attribute name="src">
122 <xsl:value-of select="$gallery" /><xsl:value-of select="@src" />
124 <xsl:attribute name="alt">
125 <xsl:value-of select="@alt" />
127 <xsl:attribute name="title">
128 <xsl:value-of select="@alt" />
134 <!-- ========================================== -->
135 <!-- = PARAGRAPH TAGS = -->
136 <!-- = (can contain inline and special tags) = -->
137 <!-- ========================================== -->
139 <xsl:template match="autor_utworu" mode="header">
140 <span class="author"><xsl:apply-templates mode="inline" /></span>
143 <xsl:template match="nazwa_utworu" mode="header">
144 <span class="title"><xsl:apply-templates mode="inline" /></span>
147 <xsl:template match="dzielo_nadrzedne" mode="header">
148 <span class="collection"><xsl:apply-templates mode="inline" /></span>
151 <xsl:template match="podtytul" mode="header">
152 <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
155 <!-- Section headers (included in index)-->
156 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
157 <xsl:call-template name="section-anchor"/>
158 <h2><xsl:apply-templates mode="inline" /></h2>
161 <xsl:template match="naglowek_scena|naglowek_rozdzial">
162 <xsl:call-template name="section-anchor"/>
163 <h3><xsl:apply-templates mode="inline" /></h3>
166 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
167 <xsl:call-template name="section-anchor"/>
168 <h4><xsl:apply-templates mode="inline" /></h4>
171 <!-- Other paragraph tags -->
172 <xsl:template match="miejsce_czas">
173 <xsl:call-template name="section-anchor"/>
174 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
177 <xsl:template match="didaskalia">
178 <xsl:call-template name="section-anchor"/>
179 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
182 <xsl:template match="lista_osoba">
183 <li><xsl:apply-templates mode="inline" /></li>
186 <xsl:template match="akap|akap_dialog|akap_cd">
187 <p class="paragraph">
188 <xsl:call-template name="section-anchor"/>
189 <xsl:apply-templates mode="inline" />
193 <xsl:template match="strofa">
195 <xsl:call-template name="section-anchor"/>
197 <xsl:when test="count(br) > 0">
198 <xsl:call-template name="verse">
199 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
200 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
202 <xsl:for-each select="br">
203 <!-- Each BR tag "consumes" text after it -->
204 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
205 <xsl:call-template name="verse">
206 <xsl:with-param name="verse-content"
207 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
208 <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]" />
213 <xsl:call-template name="verse">
214 <xsl:with-param name="verse-content" select="text() | node()" />
215 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
222 <xsl:template name="verse">
223 <xsl:param name="verse-content" />
224 <xsl:param name="verse-type" />
227 <xsl:when test="name($verse-type) = 'wers_akap'">
228 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
230 <xsl:when test="name($verse-type) = 'wers_wciety'">
232 <xsl:when test="$verse-content/@typ">
233 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
236 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
240 <xsl:when test="name($verse-type) = 'wers_cd'">
241 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
244 <xsl:apply-templates select="$verse-content" mode="inline" />
248 <xsl:template match="motto_podpis">
249 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
252 <xsl:template match="tabela">
253 <table><xsl:apply-templates /></table>
255 <xsl:template match="wiersz">
256 <tr><xsl:apply-templates /></tr>
258 <xsl:template match="kol">
259 <td><xsl:apply-templates mode="inline" /></td>
262 <xsl:template match="mat">
263 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
267 <!-- ================================================ -->
268 <!-- = INLINE TAGS = -->
269 <!-- = (contain other inline tags and special tags) = -->
270 <!-- ================================================ -->
272 <xsl:template match="pa|pe|pr|pt" mode="inline">
273 <a name="{concat('anchor-', generate-id(.))}" />
274 <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>
277 <!-- Other inline tags -->
278 <xsl:template match="mat" mode="inline">
279 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
282 <xsl:template match="didask_tekst" mode="inline">
283 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
286 <xsl:template match="slowo_obce" mode="inline">
287 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
290 <xsl:template match="tytul_dziela" mode="inline">
291 <em class="book-title">
292 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
296 <xsl:template match="wyroznienie" mode="inline">
297 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
300 <xsl:template match="osoba" mode="inline">
301 <em class="person"><xsl:apply-templates mode="inline" /></em>
305 <!-- ============================================== -->
306 <!-- = STANDALONE TAGS = -->
307 <!-- = (cannot contain any other tags) = -->
308 <!-- ============================================== -->
309 <xsl:template match="sekcja_swiatlo">
310 <hr class="spacer" />
313 <xsl:template match="sekcja_asterysk">
314 <p class="spacer-asterisk">*</p>
317 <xsl:template match="separator_linia">
318 <hr class="spacer-line" />
322 <!-- ================ -->
323 <!-- = SPECIAL TAGS = -->
324 <!-- ================ -->
326 <xsl:template match="begin" mode="inline">
327 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
328 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
329 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
333 <xsl:template match="end" mode="inline">
334 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
337 <xsl:template match="begin|end">
338 <xsl:apply-templates select='.' mode="inline" />
341 <xsl:template match="motyw" mode="inline" />
344 <xsl:template match="nota_red" mode="special">
346 <xsl:apply-templates />
351 <xsl:template name="translators">
352 <xsl:if test="//dc:contributor.translator">
353 <span class="translator">
354 <xsl:text>tłum. </xsl:text>
355 <xsl:for-each select="//dc:contributor.translator">
356 <xsl:if test="position() != 1">, </xsl:if>
357 <xsl:apply-templates mode="person" />
363 <xsl:template match="text()" mode="person">
364 <xsl:value-of select="wl:person_name(.)" />
368 <!-- ================ -->
369 <!-- = IGNORED TAGS = -->
370 <!-- ================ -->
371 <xsl:template match="extra|uwaga" />
372 <xsl:template match="extra|uwaga" mode="inline" />
374 <xsl:template match="nota_red" />
375 <xsl:template match="abstrakt" />
380 <xsl:template match="text()" />
381 <xsl:template match="text()" mode="inline">
382 <xsl:value-of select="wl:substitute_entities(.)" />
388 <xsl:template name="section-anchor">
390 this formula works as follows:
391 - get all ancestors including self
392 - choose the header (third one from root): utwor/book-type/header
393 - get all preceding siblings
395 - create an <a name="sec123"/> tag.
397 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />