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 <a name="{concat('footnote-', generate-id(.))}" />
44 <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>
46 <xsl:when test="count(akap|akap_cd|strofa) = 0">
47 <p><xsl:apply-templates select="text()|*" mode="inline" />
48 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
52 <xsl:apply-templates select="text()|*" mode="inline" />
63 <!-- ============================================================================== -->
64 <!-- = MASTER TAG = -->
65 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
66 <!-- ============================================================================== -->
67 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
68 <xsl:apply-templates select="nota_red" mode="special" />
69 <xsl:if test="nazwa_utworu">
71 <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
72 <xsl:call-template name="translators" />
75 <xsl:apply-templates />
79 <!-- ==================================================================================== -->
80 <!-- = BLOCK TAGS = -->
81 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
82 <!-- ==================================================================================== -->
83 <xsl:template match="nota">
84 <div class="note"><xsl:apply-templates /></div>
87 <xsl:template match="lista_osob">
88 <div class="person-list">
89 <h3><xsl:value-of select="naglowek_listy" /></h3>
91 <xsl:apply-templates select="lista_osoba" />
96 <xsl:template match="dedykacja">
97 <div class="dedication"><xsl:apply-templates /></div>
100 <xsl:template match="kwestia">
101 <div class="kwestia">
102 <xsl:apply-templates select="strofa|akap|didaskalia" />
106 <xsl:template match="dlugi_cytat|poezja_cyt">
107 <blockquote><xsl:apply-templates /></blockquote>
110 <xsl:template match="motto">
111 <div class="motto"><xsl:apply-templates /></div>
115 <!-- ========================================== -->
116 <!-- = PARAGRAPH TAGS = -->
117 <!-- = (can contain inline and special tags) = -->
118 <!-- ========================================== -->
120 <xsl:template match="autor_utworu" mode="header">
121 <span class="author"><xsl:apply-templates mode="inline" /></span>
124 <xsl:template match="nazwa_utworu" mode="header">
125 <span class="title"><xsl:apply-templates mode="inline" /></span>
128 <xsl:template match="dzielo_nadrzedne" mode="header">
129 <span class="collection"><xsl:apply-templates mode="inline" /></span>
132 <xsl:template match="podtytul" mode="header">
133 <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
136 <!-- Section headers (included in index)-->
137 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
138 <xsl:call-template name="section-anchor"/>
139 <h2><xsl:apply-templates mode="inline" /></h2>
142 <xsl:template match="naglowek_scena|naglowek_rozdzial">
143 <xsl:call-template name="section-anchor"/>
144 <h3><xsl:apply-templates mode="inline" /></h3>
147 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
148 <xsl:call-template name="section-anchor"/>
149 <h4><xsl:apply-templates mode="inline" /></h4>
152 <!-- Other paragraph tags -->
153 <xsl:template match="miejsce_czas">
154 <xsl:call-template name="section-anchor"/>
155 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
158 <xsl:template match="didaskalia">
159 <xsl:call-template name="section-anchor"/>
160 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
163 <xsl:template match="lista_osoba">
164 <li><xsl:apply-templates mode="inline" /></li>
167 <xsl:template match="akap|akap_dialog|akap_cd">
168 <p class="paragraph">
169 <xsl:call-template name="section-anchor"/>
170 <xsl:apply-templates mode="inline" />
174 <xsl:template match="strofa">
176 <xsl:call-template name="section-anchor"/>
178 <xsl:when test="count(br) > 0">
179 <xsl:call-template name="verse">
180 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
181 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
183 <xsl:for-each select="br">
184 <!-- Each BR tag "consumes" text after it -->
185 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
186 <xsl:call-template name="verse">
187 <xsl:with-param name="verse-content"
188 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
189 <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]" />
194 <xsl:call-template name="verse">
195 <xsl:with-param name="verse-content" select="text() | node()" />
196 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
203 <xsl:template name="verse">
204 <xsl:param name="verse-content" />
205 <xsl:param name="verse-type" />
208 <xsl:when test="name($verse-type) = 'wers_akap'">
209 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
211 <xsl:when test="name($verse-type) = 'wers_wciety'">
213 <xsl:when test="$verse-content/@typ">
214 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
217 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
221 <xsl:when test="name($verse-type) = 'wers_cd'">
222 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
225 <xsl:apply-templates select="$verse-content" mode="inline" />
229 <xsl:template match="motto_podpis">
230 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
234 <!-- ================================================ -->
235 <!-- = INLINE TAGS = -->
236 <!-- = (contain other inline tags and special tags) = -->
237 <!-- ================================================ -->
239 <xsl:template match="pa|pe|pr|pt" mode="inline">
240 <a name="{concat('anchor-', generate-id(.))}" />
241 <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>
244 <!-- Other inline tags -->
245 <xsl:template match="mat" mode="inline">
246 <em class="math"><xsl:apply-templates mode="inline" /></em>
249 <xsl:template match="didask_tekst" mode="inline">
250 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
253 <xsl:template match="slowo_obce" mode="inline">
254 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
257 <xsl:template match="tytul_dziela" mode="inline">
258 <em class="book-title">
259 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
263 <xsl:template match="wyroznienie" mode="inline">
264 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
267 <xsl:template match="osoba" mode="inline">
268 <em class="person"><xsl:apply-templates mode="inline" /></em>
272 <!-- ============================================== -->
273 <!-- = STANDALONE TAGS = -->
274 <!-- = (cannot contain any other tags) = -->
275 <!-- ============================================== -->
276 <xsl:template match="sekcja_swiatlo">
277 <hr class="spacer" />
280 <xsl:template match="sekcja_asterysk">
281 <p class="spacer-asterisk">*</p>
284 <xsl:template match="separator_linia">
285 <hr class="spacer-line" />
289 <!-- ================ -->
290 <!-- = SPECIAL TAGS = -->
291 <!-- ================ -->
293 <xsl:template match="begin" mode="inline">
294 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
295 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
296 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
300 <xsl:template match="end" mode="inline">
301 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
304 <xsl:template match="begin|end">
305 <xsl:apply-templates select='.' mode="inline" />
308 <xsl:template match="motyw" mode="inline" />
311 <xsl:template match="nota_red" mode="special">
313 <xsl:apply-templates />
318 <xsl:template name="translators">
319 <xsl:if test="//dc:contributor.translator">
320 <span class="translator">
321 <xsl:text>tłum. </xsl:text>
322 <xsl:for-each select="//dc:contributor.translator">
323 <xsl:if test="position() != 1">, </xsl:if>
324 <xsl:apply-templates mode="person" />
330 <xsl:template match="text()" mode="person">
331 <xsl:value-of select="wl:person_name(.)" />
335 <!-- ================ -->
336 <!-- = IGNORED TAGS = -->
337 <!-- ================ -->
338 <xsl:template match="extra|uwaga" />
339 <xsl:template match="extra|uwaga" mode="inline" />
341 <xsl:template match="nota_red" />
346 <xsl:template match="text()" />
347 <xsl:template match="text()" mode="inline">
348 <xsl:value-of select="wl:substitute_entities(.)" />
354 <xsl:template name="section-anchor">
356 this formula works as follows:
357 - get all ancestors including self
358 - choose the header (third one from root): utwor/book-type/header
359 - get all preceding siblings
361 - create an <a name="sec123"/> tag.
363 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />