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' />
64 <xsl:when test="//dc:contributor">Thank you for your contribution, <xsl:value-of select="//dc:contributor"/>!</xsl:when>
65 <xsl:otherwise>Thank you for all your contributions!</xsl:otherwise>
70 <xsl:if test="@data-cover-width">
71 <cmd name="makecover">
73 <parm><xsl:value-of select="210 * @data-cover-height div @data-cover-width" />mm</parm>
76 <!--cmd name="maketitle" /-->
78 <!--cmd name="tytul"><parm>
80 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
81 <!- title in master ->
82 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
83 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
84 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
85 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
86 <!- dc in master or not ->
87 <cmd name="translatorsline" />
90 <!- look for author title in dc ->
91 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
92 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
99 <xsl:if test="@data-cover-by">Cover image:
101 <xsl:when test="@data-cover-source">
102 \href{\datacoversource}{\datacoverby}.
112 <cmd name="editorialsection" />
114 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
115 <xsl:apply-templates select="utwor" mode="part" />
120 <xsl:template match="utwor" mode="part">
121 <cmd name="newpage" />
122 <cmd name="tytul"><parm>
125 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/motyw" mode="inline"/>
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)/dzielo_nadrzedne" mode="title" />
131 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
132 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
133 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
136 <!-- look for title in dc -->
137 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
138 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
143 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
144 <xsl:apply-templates select="utwor" mode="part" />
147 <!-- =================== -->
148 <!-- = MAIN TITLE PAGE = -->
149 <!-- = (from DC) = -->
150 <!-- =================== -->
152 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
153 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
156 <xsl:template match="rdf:RDF" mode="titlepage">
158 \def\authors{<xsl:call-template name="authors" />}
160 \title{<xsl:apply-templates select=".//dc:title" mode="inline" />}
161 \def\translatorsline{<xsl:call-template name="translators" />}
163 \def\bookurl{<xsl:value-of select=".//dc:identifier.url" />}
165 \def\rightsinfo{Ten utwór nie jest chroniony prawem autorskim i~znajduje się w~domenie
166 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
167 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
168 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
169 te dodatkowe materiały udostępnione są na licencji
170 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
171 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
172 <xsl:if test=".//dc:rights.license">
173 \def\rightsinfo{This book is available under the terms of
174 \href{<xsl:value-of select=".//dc:rights.license" />}{<xsl:value-of select=".//dc:rights" />}.}
178 <xsl:if test=".//dc:source">
179 Tekst opracowany na podstawie: <xsl:apply-templates select=".//dc:source" mode="inline" />
182 \def\description{<xsl:apply-templates select=".//dc:description" mode="inline" />}
183 \def\editors{<xsl:call-template name="editors" />}
188 <!-- ============== -->
189 <!-- = BOOK TITLE = -->
190 <!-- = (from DC) = -->
191 <!-- ============== -->
193 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
194 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
197 <xsl:template match="rdf:RDF" mode="dctitle">
198 <cmd name="nazwapodutworu"><parm>
199 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
203 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
204 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
207 <xsl:template match="rdf:RDF" mode="firstdctitle">
208 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
209 <cmd name="nazwautworu"><parm>
210 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
212 <cmd name="translatorsline" />
216 <!-- ============================================================================== -->
217 <!-- = MASTER TAG = -->
218 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
219 <!-- ============================================================================== -->
220 <!-- ==================================================================================== -->
221 <!-- = BLOCK TAGS = -->
222 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
223 <!-- ==================================================================================== -->
226 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
228 <xsl:attribute name="name">
229 <xsl:value-of select="wl:texcommand(name())" />
231 <parm><xsl:apply-templates/></parm>
235 <xsl:template match="lista_osob">
236 <cmd name="listaosob">
237 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
238 <parm><xsl:apply-templates select="lista_osoba" /></parm>
242 <xsl:template match="kwestia">
244 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
249 <!-- ========================================== -->
250 <!-- = PARAGRAPH TAGS = -->
251 <!-- = (can contain inline and special tags) = -->
252 <!-- ========================================== -->
254 <!-- only in root -->
256 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
259 <xsl:attribute name="name">
260 <xsl:value-of select="wl:texcommand(name())" />
262 <parm><xsl:apply-templates mode="inline"/></parm>
268 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">
270 <xsl:attribute name="name">
271 <xsl:value-of select="wl:texcommand(name())" />
273 <parm><xsl:apply-templates mode="inline"/></parm>
277 <xsl:template match="strofa">
278 <cmd name="strofa"><parm>
280 <xsl:when test="count(br) > 0">
281 <xsl:call-template name="verse">
282 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
283 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
285 <xsl:for-each select="br">
286 <TeXML escape="0">\\{}</TeXML>
287 <!-- Each BR tag "consumes" text after it -->
288 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
289 <xsl:call-template name="verse">
290 <xsl:with-param name="verse-content"
291 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
292 <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]" />
297 <xsl:call-template name="verse">
298 <xsl:with-param name="verse-content" select="text() | node()" />
299 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
307 <xsl:template name="verse">
308 <xsl:param name="verse-content" />
309 <xsl:param name="verse-type" />
312 <xsl:attribute name="name">
314 <xsl:when test="$verse-type != ''">
315 <xsl:value-of select='wl:texcommand(name($verse-type))' />
317 <xsl:otherwise>wers</xsl:otherwise>
320 <xsl:if test="string($verse-content/@typ)">
321 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
323 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
327 <!-- ================================================ -->
328 <!-- = INLINE TAGS = -->
329 <!-- = (contain other inline tags and special tags) = -->
330 <!-- ================================================ -->
332 <xsl:template mode="inline"
333 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
335 <xsl:attribute name="name">
336 <xsl:value-of select="wl:texcommand(name())" />
338 <parm><xsl:apply-templates mode="inline"/></parm>
344 <xsl:template match="tytul_dziela" mode="inline">
345 <cmd name="tytuldziela"><parm>
346 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
352 <!-- ============================================== -->
353 <!-- = STANDALONE TAGS = -->
354 <!-- = (cannot contain any other tags) = -->
355 <!-- ============================================== -->
357 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
359 <xsl:attribute name="name">
360 <xsl:value-of select="wl:texcommand(name())" />
365 <xsl:template match="ilustr">
367 <xsl:attribute name="name">
368 <xsl:value-of select="wl:texcommand(name())" />
370 <parm><xsl:value-of select="@src" /></parm>
371 <parm><xsl:apply-templates mode="inline" /></parm>
375 <xsl:template match="@*|node()" mode="identity">
377 <xsl:apply-templates select="@*|node()" mode="identity"/>
383 <xsl:template match="dmath">
385 <xsl:apply-templates mode="identity"/>
389 <xsl:template match="math" mode="inline">
391 <xsl:apply-templates mode="identity"/>
395 <xsl:template match="table">
396 <xsl:if test="@caption">
397 <group><cmd name="Large"/><xsl:value-of select="@caption"/></group><cmd name="newline"/>
400 <parm><xsl:value-of select="@spec"/></parm>
401 <xsl:apply-templates />
405 <xsl:template match="r">
406 <xsl:apply-templates />
410 <xsl:template match="c">
411 <xsl:apply-templates mode="inline"/>
412 <xsl:if test="position() < last()-1">
416 <xsl:template match="hr">
420 <!-- ================ -->
421 <!-- = SPECIAL TAGS = -->
422 <!-- ================ -->
426 <xsl:template match="begin|end|motyw">
427 <xsl:apply-templates select='.' mode="inline" />
430 <xsl:template match="begin" mode="inline" />
431 <xsl:template match="end" mode="inline" />
433 <xsl:template match="motyw" mode="inline">
435 <xsl:if test="@moved">
436 <opt name="moved"><xsl:value-of select="@moved" /></opt>
438 <parm><xsl:apply-templates mode="inline" /></parm>
442 <xsl:template name="authors">
443 <xsl:for-each select=".//dc:creator_parsed">
444 <xsl:if test="position() != 1">, </xsl:if>
445 <xsl:apply-templates mode="inline" />
449 <xsl:template name="editors">
450 <xsl:if test=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed">
451 <xsl:text>Technical editors: </xsl:text>
452 <xsl:for-each select=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed[not(.//dc:contributor.editor_parsed/text()=text())]">
453 <!--xsl:sort select="@sortkey" /-->
454 <xsl:if test="position() != 1">, </xsl:if>
455 <xsl:apply-templates mode="inline" />
460 <xsl:template name="translators">
461 <xsl:if test=".//dc:contributor.translator_parsed">
462 <cmd name='translator'><parm>
463 <xsl:for-each select=".//dc:contributor.translator_parsed">
464 <xsl:if test="position() != 1">, </xsl:if>
465 <xsl:apply-templates mode="inline" />
472 <!-- ============== -->
473 <!-- = ADDED TAGS = -->
474 <!-- ============== -->
477 <xsl:template match="dywiz" mode="inline">
481 <xsl:template match="nbsp" mode="inline">
485 <xsl:template match="alien" mode="inline">
488 <xsl:apply-templates mode="inline" />
492 <!-- ================ -->
493 <!-- = IGNORED TAGS = -->
494 <!-- ================ -->
495 <xsl:template match="extra|uwaga" />
496 <xsl:template match="extra|uwaga" mode="inline" />
498 <xsl:template match="nota_red" />
503 <xsl:template match="text()" />
504 <xsl:template match="text()" mode="inline">
505 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
506 <xsl:text> </xsl:text>
509 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
511 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
512 <xsl:text> </xsl:text>