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/"
11 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
13 <xsl:output encoding="utf-8" indent="yes" version="2.0" />
15 <xsl:template match="utwor">
16 <TeXML xmlns="http://getfo.sourceforge.net/texml/ns1">
18 \documentclass[<xsl:value-of select="@customizations"/>]{wl}
20 <!-- flags and values set on root -->
22 \newif\ifflaglessadvertising
23 <xsl:for-each select="@*[starts-with(name(), 'flag-')]">
25 <xsl:attribute name="name"><xsl:value-of select="wl:texcommand(name())" />true</xsl:attribute>
29 <xsl:for-each select="@*[starts-with(name(), 'data-')]">
31 \def\<xsl:value-of select="wl:texcommand(name())" />{<TeXML escape="1"><xsl:value-of select="."/></TeXML>}
37 <xsl:when test="@morefloats = 'new'">
39 \usepackage[maxfloats=64]{morefloats}
42 <xsl:when test="@morefloats = 'old'">
44 \usepackage{morefloats}
47 <xsl:when test="@morefloats = 'none'" />
50 \IfFileExists{morefloats.sty}{
51 \usepackage{morefloats}
57 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
58 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
61 <xsl:if test="@data-cover-width">
62 <cmd name="makecover">
63 <parm><xsl:value-of select="210 * @data-cover-width div @data-cover-height" />mm</parm>
67 <cmd name="maketitle" />
69 <cmd name="tytul"><parm>
71 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
72 <!-- title in master -->
73 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
74 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
75 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
76 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
77 <!-- dc in master or not -->
78 <cmd name="translatorsline" />
81 <!-- look for author title in dc -->
82 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
83 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
87 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
88 <xsl:apply-templates select="utwor" mode="part" />
91 <xsl:if test="@data-cover-by">
92 \def\coverby{Okładka na podstawie:
94 <xsl:when test="@data-cover-source">
95 \href{\datacoversource}{\datacoverby}
103 \def\editors{<TeXML escape="1"><xsl:call-template name="editors" /></TeXML>}
104 <xsl:if test="@funders">
105 \def\funders{Publikację ufundowali i ufundowały:
106 <TeXML escape="1"><xsl:value-of select="@funders" /></TeXML>.}
109 <xsl:if test="data-sponsor">
111 \scriptsize Sfinansowano ze~środków:\\
112 <xsl:for-each select="data-sponsor">
113 \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
119 <cmd name="editorialsection" />
125 <xsl:template match="utwor" mode="part">
126 <cmd name="tytul"><parm>
128 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
129 <!-- title in master -->
130 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
131 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
134 <!-- look for title in dc -->
135 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
136 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
141 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
142 <xsl:apply-templates select="utwor" mode="part" />
145 <!-- =================== -->
146 <!-- = MAIN TITLE PAGE = -->
147 <!-- = (from DC) = -->
148 <!-- =================== -->
150 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
151 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
154 <xsl:template match="rdf:RDF" mode="titlepage">
156 \def\authors{<xsl:call-template name="authors" />}
158 \title{<xsl:apply-templates select=".//dc:title" mode="inline" />}
159 \def\translatorsline{<xsl:call-template name="translators" />}
161 \def\bookurl{<xsl:value-of select=".//dc:identifier.url" />}
163 \def\rightsinfo{Ten utwór nie jest objęty majątkowym prawem autorskim i~znajduje się w~domenie
164 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
165 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
166 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
167 te dodatkowe materiały udostępnione są na licencji
168 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
169 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
170 <xsl:if test=".//dc:rights.license">
171 \def\rightsinfo{Ten utwór jest udostepniony na licencji
172 \href{<xsl:value-of select=".//dc:rights.license" />}{<xsl:value-of select=".//dc:rights" />}.}
176 <xsl:if test=".//dc:source">
177 Tekst opracowany na podstawie: <xsl:apply-templates select=".//dc:source" mode="inline" />
180 \def\description{<xsl:apply-templates select=".//dc:description" mode="inline" />}
185 <!-- ============== -->
186 <!-- = BOOK TITLE = -->
187 <!-- = (from DC) = -->
188 <!-- ============== -->
190 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
191 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
194 <xsl:template match="rdf:RDF" mode="dctitle">
195 <cmd name="nazwapodutworu"><parm>
196 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
200 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
201 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
204 <xsl:template match="rdf:RDF" mode="firstdctitle">
205 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
206 <cmd name="nazwautworu"><parm>
207 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
209 <cmd name="translatorsline" />
213 <!-- ============================================================================== -->
214 <!-- = MASTER TAG = -->
215 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
216 <!-- ============================================================================== -->
217 <!-- ==================================================================================== -->
218 <!-- = BLOCK TAGS = -->
219 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
220 <!-- ==================================================================================== -->
223 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
225 <xsl:attribute name="name">
226 <xsl:value-of select="wl:texcommand(name())" />
228 <parm><xsl:apply-templates/></parm>
232 <xsl:template match="lista_osob">
233 <cmd name="listaosob">
234 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
235 <parm><xsl:apply-templates select="lista_osoba" /></parm>
239 <xsl:template match="kwestia">
241 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
246 <!-- ========================================== -->
247 <!-- = PARAGRAPH TAGS = -->
248 <!-- = (can contain inline and special tags) = -->
249 <!-- ========================================== -->
251 <!-- only in root -->
253 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
256 <xsl:attribute name="name">
257 <xsl:value-of select="wl:texcommand(name())" />
259 <parm><xsl:apply-templates mode="inline"/></parm>
265 match="naglowek_akt|naglowek_czesc|srodtytul|naglowek_osoba|naglowek_podrozdzial|naglowek_scena|naglowek_rozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy">
267 <xsl:attribute name="name">
268 <xsl:value-of select="wl:texcommand(name())" />
270 <parm><xsl:apply-templates mode="inline"/></parm>
274 <xsl:template match="strofa">
275 <cmd name="strofa"><parm>
277 <xsl:when test="count(br) > 0">
278 <xsl:call-template name="verse">
279 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
280 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
282 <xsl:for-each select="br">
283 <TeXML escape="0">\\{}</TeXML>
284 <!-- Each BR tag "consumes" text after it -->
285 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
286 <xsl:call-template name="verse">
287 <xsl:with-param name="verse-content"
288 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
289 <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]" />
294 <xsl:call-template name="verse">
295 <xsl:with-param name="verse-content" select="text() | node()" />
296 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
304 <xsl:template name="verse">
305 <xsl:param name="verse-content" />
306 <xsl:param name="verse-type" />
309 <xsl:attribute name="name">
311 <xsl:when test="$verse-type != ''">
312 <xsl:value-of select='wl:texcommand(name($verse-type))' />
314 <xsl:otherwise>wers</xsl:otherwise>
317 <xsl:if test="string($verse-content/@typ)">
318 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
320 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
324 <!-- ================================================ -->
325 <!-- = INLINE TAGS = -->
326 <!-- = (contain other inline tags and special tags) = -->
327 <!-- ================================================ -->
329 <xsl:template mode="inline"
330 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
332 <xsl:attribute name="name">
333 <xsl:value-of select="wl:texcommand(name())" />
335 <parm><xsl:apply-templates mode="inline"/></parm>
341 <xsl:template match="tytul_dziela" mode="inline">
342 <cmd name="tytuldziela"><parm>
343 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
349 <!-- ============================================== -->
350 <!-- = STANDALONE TAGS = -->
351 <!-- = (cannot contain any other tags) = -->
352 <!-- ============================================== -->
354 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
356 <xsl:attribute name="name">
357 <xsl:value-of select="wl:texcommand(name())" />
363 <!-- ================ -->
364 <!-- = SPECIAL TAGS = -->
365 <!-- ================ -->
369 <xsl:template match="begin|end|motyw">
370 <xsl:apply-templates select='.' mode="inline" />
373 <xsl:template match="begin" mode="inline" />
374 <xsl:template match="end" mode="inline" />
376 <xsl:template match="motyw" mode="inline">
378 <xsl:if test="@moved">
379 <opt name="moved"><xsl:value-of select="@moved" /></opt>
381 <parm><xsl:apply-templates mode="inline" /></parm>
385 <xsl:template name="authors">
386 <xsl:for-each select=".//dc:creator_parsed">
387 <xsl:if test="position() != 1">, </xsl:if>
388 <xsl:apply-templates mode="inline" />
392 <xsl:template name="editors">
393 <xsl:if test="@editors">
394 <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
395 <xsl:value-of select="@editors" />
396 <xsl:text>.</xsl:text>
400 <xsl:template name="translators">
401 <xsl:if test=".//dc:contributor.translator_parsed">
402 <cmd name='translator'><parm>
403 <xsl:for-each select=".//dc:contributor.translator_parsed">
404 <xsl:if test="position() != 1">, </xsl:if>
405 <xsl:apply-templates mode="inline" />
412 <!-- ============== -->
413 <!-- = ADDED TAGS = -->
414 <!-- ============== -->
417 <xsl:template match="dywiz" mode="inline">
421 <xsl:template match="nbsp" mode="inline">
425 <xsl:template match="alien" mode="inline">
428 <xsl:apply-templates mode="inline" />
432 <!-- ================ -->
433 <!-- = IGNORED TAGS = -->
434 <!-- ================ -->
435 <xsl:template match="extra|uwaga" />
436 <xsl:template match="extra|uwaga" mode="inline" />
438 <xsl:template match="nota_red" />
443 <xsl:template match="text()" />
444 <xsl:template match="text()" mode="inline">
445 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
446 <xsl:text> </xsl:text>
449 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
451 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
452 <xsl:text> </xsl:text>