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{<xsl:call-template name="editors" />}
106 <cmd name="editorialsection" />
112 <xsl:template match="utwor" mode="part">
113 <cmd name="tytul"><parm>
115 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
116 <!-- title in master -->
117 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
118 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
121 <!-- look for title in dc -->
122 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
123 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
128 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
129 <xsl:apply-templates select="utwor" mode="part" />
132 <!-- =================== -->
133 <!-- = MAIN TITLE PAGE = -->
134 <!-- = (from DC) = -->
135 <!-- =================== -->
137 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
138 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
141 <xsl:template match="rdf:RDF" mode="titlepage">
143 \def\authors{<xsl:call-template name="authors" />}
145 \title{<xsl:apply-templates select=".//dc:title" mode="inline" />}
146 \def\translatorsline{<xsl:call-template name="translators" />}
148 \def\bookurl{<xsl:value-of select=".//dc:identifier.url" />}
150 \def\rightsinfo{Ten utwór nie jest chroniony prawem autorskim i~znajduje się w~domenie
151 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
152 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
153 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
154 te dodatkowe materiały udostępnione są na licencji
155 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
156 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
157 <xsl:if test=".//dc:rights.license">
158 \def\rightsinfo{Ten utwór jest udostepniony na licencji
159 \href{<xsl:value-of select=".//dc:rights.license" />}{<xsl:value-of select=".//dc:rights" />}.}
163 <xsl:if test=".//dc:source">
164 Tekst opracowany na podstawie: <xsl:apply-templates select=".//dc:source" mode="inline" />
167 \def\description{<xsl:apply-templates select=".//dc:description" mode="inline" />}
168 \def\editors{<xsl:call-template name="editors" />}
173 <!-- ============== -->
174 <!-- = BOOK TITLE = -->
175 <!-- = (from DC) = -->
176 <!-- ============== -->
178 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
179 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
182 <xsl:template match="rdf:RDF" mode="dctitle">
183 <cmd name="nazwapodutworu"><parm>
184 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
188 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
189 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
192 <xsl:template match="rdf:RDF" mode="firstdctitle">
193 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
194 <cmd name="nazwautworu"><parm>
195 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
197 <cmd name="translatorsline" />
201 <!-- ============================================================================== -->
202 <!-- = MASTER TAG = -->
203 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
204 <!-- ============================================================================== -->
205 <!-- ==================================================================================== -->
206 <!-- = BLOCK TAGS = -->
207 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
208 <!-- ==================================================================================== -->
211 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
213 <xsl:attribute name="name">
214 <xsl:value-of select="wl:texcommand(name())" />
216 <parm><xsl:apply-templates/></parm>
220 <xsl:template match="lista_osob">
221 <cmd name="listaosob">
222 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
223 <parm><xsl:apply-templates select="lista_osoba" /></parm>
227 <xsl:template match="kwestia">
229 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
234 <!-- ========================================== -->
235 <!-- = PARAGRAPH TAGS = -->
236 <!-- = (can contain inline and special tags) = -->
237 <!-- ========================================== -->
239 <!-- only in root -->
241 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
244 <xsl:attribute name="name">
245 <xsl:value-of select="wl:texcommand(name())" />
247 <parm><xsl:apply-templates mode="inline"/></parm>
253 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">
255 <xsl:attribute name="name">
256 <xsl:value-of select="wl:texcommand(name())" />
258 <parm><xsl:apply-templates mode="inline"/></parm>
262 <xsl:template match="strofa">
263 <cmd name="strofa"><parm>
265 <xsl:when test="count(br) > 0">
266 <xsl:call-template name="verse">
267 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
268 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
270 <xsl:for-each select="br">
271 <TeXML escape="0">\\{}</TeXML>
272 <!-- Each BR tag "consumes" text after it -->
273 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
274 <xsl:call-template name="verse">
275 <xsl:with-param name="verse-content"
276 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
277 <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]" />
282 <xsl:call-template name="verse">
283 <xsl:with-param name="verse-content" select="text() | node()" />
284 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
292 <xsl:template name="verse">
293 <xsl:param name="verse-content" />
294 <xsl:param name="verse-type" />
297 <xsl:attribute name="name">
299 <xsl:when test="$verse-type != ''">
300 <xsl:value-of select='wl:texcommand(name($verse-type))' />
302 <xsl:otherwise>wers</xsl:otherwise>
305 <xsl:if test="string($verse-content/@typ)">
306 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
308 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
312 <!-- ================================================ -->
313 <!-- = INLINE TAGS = -->
314 <!-- = (contain other inline tags and special tags) = -->
315 <!-- ================================================ -->
317 <xsl:template mode="inline"
318 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
320 <xsl:attribute name="name">
321 <xsl:value-of select="wl:texcommand(name())" />
323 <parm><xsl:apply-templates mode="inline"/></parm>
329 <xsl:template match="tytul_dziela" mode="inline">
330 <cmd name="tytuldziela"><parm>
331 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
337 <!-- ============================================== -->
338 <!-- = STANDALONE TAGS = -->
339 <!-- = (cannot contain any other tags) = -->
340 <!-- ============================================== -->
342 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
344 <xsl:attribute name="name">
345 <xsl:value-of select="wl:texcommand(name())" />
351 <!-- ================ -->
352 <!-- = SPECIAL TAGS = -->
353 <!-- ================ -->
357 <xsl:template match="begin|end|motyw">
358 <xsl:apply-templates select='.' mode="inline" />
361 <xsl:template match="begin" mode="inline" />
362 <xsl:template match="end" mode="inline" />
364 <xsl:template match="motyw" mode="inline">
366 <xsl:if test="@moved">
367 <opt name="moved"><xsl:value-of select="@moved" /></opt>
369 <parm><xsl:apply-templates mode="inline" /></parm>
373 <xsl:template name="authors">
374 <xsl:for-each select=".//dc:creator_parsed">
375 <xsl:if test="position() != 1">, </xsl:if>
376 <xsl:apply-templates mode="inline" />
380 <xsl:template name="editors">
381 <xsl:if test="@editors">
382 <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
383 <xsl:value-of select="@editors" />
384 <xsl:text>.</xsl:text>
388 <xsl:template name="translators">
389 <xsl:if test=".//dc:contributor.translator_parsed">
390 <cmd name='translator'><parm>
391 <xsl:for-each select=".//dc:contributor.translator_parsed">
392 <xsl:if test="position() != 1">, </xsl:if>
393 <xsl:apply-templates mode="inline" />
400 <!-- ============== -->
401 <!-- = ADDED TAGS = -->
402 <!-- ============== -->
405 <xsl:template match="dywiz" mode="inline">
409 <xsl:template match="nbsp" mode="inline">
413 <xsl:template match="alien" mode="inline">
416 <xsl:apply-templates mode="inline" />
420 <!-- ================ -->
421 <!-- = IGNORED TAGS = -->
422 <!-- ================ -->
423 <xsl:template match="extra|uwaga" />
424 <xsl:template match="extra|uwaga" mode="inline" />
426 <xsl:template match="nota_red" />
431 <xsl:template match="text()" />
432 <xsl:template match="text()" mode="inline">
433 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
434 <xsl:text> </xsl:text>
437 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
439 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
440 <xsl:text> </xsl:text>