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>
234 <xsl:template match="tabela">
235 <table><xsl:apply-templates /></table>
237 <xsl:template match="wiersz">
238 <tr><xsl:apply-templates /></tr>
240 <xsl:template match="kol">
241 <td><xsl:apply-templates mode="inline" /></td>
244 <xsl:template match="mat">
245 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
249 <!-- ================================================ -->
250 <!-- = INLINE TAGS = -->
251 <!-- = (contain other inline tags and special tags) = -->
252 <!-- ================================================ -->
254 <xsl:template match="pa|pe|pr|pt" mode="inline">
255 <a name="{concat('anchor-', generate-id(.))}" />
256 <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>
259 <!-- Other inline tags -->
260 <xsl:template match="mat" mode="inline">
261 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
264 <xsl:template match="didask_tekst" mode="inline">
265 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
268 <xsl:template match="slowo_obce" mode="inline">
269 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
272 <xsl:template match="tytul_dziela" mode="inline">
273 <em class="book-title">
274 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
278 <xsl:template match="wyroznienie" mode="inline">
279 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
282 <xsl:template match="osoba" mode="inline">
283 <em class="person"><xsl:apply-templates mode="inline" /></em>
287 <!-- ============================================== -->
288 <!-- = STANDALONE TAGS = -->
289 <!-- = (cannot contain any other tags) = -->
290 <!-- ============================================== -->
291 <xsl:template match="sekcja_swiatlo">
292 <hr class="spacer" />
295 <xsl:template match="sekcja_asterysk">
296 <p class="spacer-asterisk">*</p>
299 <xsl:template match="separator_linia">
300 <hr class="spacer-line" />
304 <!-- ================ -->
305 <!-- = SPECIAL TAGS = -->
306 <!-- ================ -->
308 <xsl:template match="begin" mode="inline">
309 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
310 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
311 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
315 <xsl:template match="end" mode="inline">
316 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
319 <xsl:template match="begin|end">
320 <xsl:apply-templates select='.' mode="inline" />
323 <xsl:template match="motyw" mode="inline" />
326 <xsl:template match="nota_red" mode="special">
328 <xsl:apply-templates />
333 <xsl:template name="translators">
334 <xsl:if test="//dc:contributor.translator">
335 <span class="translator">
336 <xsl:text>tłum. </xsl:text>
337 <xsl:for-each select="//dc:contributor.translator">
338 <xsl:if test="position() != 1">, </xsl:if>
339 <xsl:apply-templates mode="person" />
345 <xsl:template match="text()" mode="person">
346 <xsl:value-of select="wl:person_name(.)" />
350 <!-- ================ -->
351 <!-- = IGNORED TAGS = -->
352 <!-- ================ -->
353 <xsl:template match="extra|uwaga" />
354 <xsl:template match="extra|uwaga" mode="inline" />
356 <xsl:template match="nota_red" />
357 <xsl:template match="abstrakt" />
362 <xsl:template match="text()" />
363 <xsl:template match="text()" mode="inline">
364 <xsl:value-of select="wl:substitute_entities(.)" />
370 <xsl:template name="section-anchor">
372 this formula works as follows:
373 - get all ancestors including self
374 - choose the header (third one from root): utwor/book-type/header
375 - get all preceding siblings
377 - create an <a name="sec123"/> tag.
379 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />