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=53]{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">
64 <parm><xsl:value-of select="210 * @data-cover-height div @data-cover-width" />mm</parm>
67 <xsl:if test="@thanks">
69 \def\thanknote{<TeXML escape="1"><xsl:value-of select="@thanks" /></TeXML>}
72 <cmd name="maketitle" />
74 <cmd name="tytul"><parm>
76 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
77 <!-- title in master -->
78 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
79 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
80 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
81 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
82 <!-- dc in master or not -->
83 <cmd name="translatorsline" />
86 <!-- look for author title in dc -->
87 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
88 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
92 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
93 <xsl:apply-templates select="utwor" mode="part" />
96 <xsl:if test="@data-cover-by">
97 \def\coverby{Okładka na podstawie:
99 <xsl:when test="@data-cover-source">
100 \href{\datacoversource}{\datacoverby}
108 \def\editors{<TeXML escape="1"><xsl:call-template name="editors" /></TeXML>}
109 <xsl:if test="@funders">
110 \def\funders{Publikację wsparli i wsparły:
111 <TeXML escape="1"><xsl:value-of select="@funders" /></TeXML>.}
114 <xsl:if test="@sponsor-note|data-sponsor">
118 <xsl:when test="@sponsor-note">
119 <TeXML escape="1"><xsl:value-of select="@sponsor-note" /></TeXML>
122 Sfinansowano ze~środków:
128 <xsl:apply-templates select="data-sponsor" mode="sponsor" />
133 <cmd name="editorialsection" />
139 <xsl:template match="utwor" mode="part">
140 <cmd name="tytul"><parm>
142 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
143 <!-- title in master -->
144 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
145 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
148 <!-- look for title in dc -->
149 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
150 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
155 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
156 <xsl:apply-templates select="utwor" mode="part" />
159 <!-- =================== -->
160 <!-- = MAIN TITLE PAGE = -->
161 <!-- = (from DC) = -->
162 <!-- =================== -->
164 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
165 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
168 <xsl:template match="rdf:RDF" mode="titlepage">
170 \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
172 \title{<TeXML escape="1"><xsl:apply-templates select=".//dc:title" mode="inline" /></TeXML>}
173 \def\translatorsline{<TeXML escape="1"><xsl:call-template name="translators" /></TeXML>}
175 \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
177 \def\rightsinfo{Ten utwór nie jest objęty majątkowym prawem autorskim i~znajduje się w~domenie
178 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
179 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
180 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
181 te dodatkowe materiały udostępnione są na licencji
182 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
183 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
184 <xsl:if test=".//dc:rights.license">
185 \def\rightsinfo{Ten utwór jest udostepniony na licencji
186 \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
190 <xsl:if test=".//dc:source">
191 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
195 <xsl:if test=".//dc:publisher">
198 <xsl:for-each select=".//dc:publisher/text()">
199 <xsl:value-of select="."/>
200 <xsl:if test="not(position() = last())">, </xsl:if>
205 \def\description{<TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
206 <xsl:if test=".//meta[@id='pdf-id']">
207 <xsl:variable name="isbn" select=".//meta[@id='pdf-id']"/>
208 \def\isbn{ISBN <xsl:value-of select="substring-after($isbn, 'ISBN-')"/>}
214 <!-- ============== -->
215 <!-- = BOOK TITLE = -->
216 <!-- = (from DC) = -->
217 <!-- ============== -->
219 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
220 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
223 <xsl:template match="rdf:RDF" mode="dctitle">
224 <cmd name="nazwapodutworu"><parm>
225 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
229 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
230 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
233 <xsl:template match="rdf:RDF" mode="firstdctitle">
234 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
235 <cmd name="nazwautworu"><parm>
236 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
238 <cmd name="translatorsline" />
242 <!-- ============================================================================== -->
243 <!-- = MASTER TAG = -->
244 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
245 <!-- ============================================================================== -->
246 <!-- ==================================================================================== -->
247 <!-- = BLOCK TAGS = -->
248 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
249 <!-- ==================================================================================== -->
252 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
254 <xsl:attribute name="name">
255 <xsl:value-of select="wl:texcommand(name())" />
257 <parm><xsl:apply-templates/></parm>
261 <xsl:template match="lista_osob">
262 <cmd name="listaosob">
263 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
264 <parm><xsl:apply-templates select="lista_osoba" /></parm>
268 <xsl:template match="kwestia">
270 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
274 <xsl:template match="ilustr">
276 <parm><xsl:value-of select="@src" /></parm>
277 <parm><xsl:value-of select="@alt" /></parm>
281 <!-- ========================================== -->
282 <!-- = PARAGRAPH TAGS = -->
283 <!-- = (can contain inline and special tags) = -->
284 <!-- ========================================== -->
286 <!-- only in root -->
288 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
291 <xsl:attribute name="name">
292 <xsl:value-of select="wl:texcommand(name())" />
294 <parm><xsl:apply-templates mode="inline"/></parm>
300 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">
302 <xsl:attribute name="name">
303 <xsl:value-of select="wl:texcommand(name())" />
305 <parm><xsl:apply-templates mode="inline"/></parm>
309 <xsl:template match="strofa">
310 <cmd name="strofa"><parm>
312 <xsl:when test="count(br) > 0">
313 <xsl:call-template name="verse">
314 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
315 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
317 <xsl:for-each select="br">
318 <TeXML escape="0">\\{}</TeXML>
319 <!-- Each BR tag "consumes" text after it -->
320 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
321 <xsl:call-template name="verse">
322 <xsl:with-param name="verse-content"
323 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
324 <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]" />
329 <xsl:call-template name="verse">
330 <xsl:with-param name="verse-content" select="text() | node()" />
331 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
339 <xsl:template name="verse">
340 <xsl:param name="verse-content" />
341 <xsl:param name="verse-type" />
344 <xsl:attribute name="name">
346 <xsl:when test="$verse-type != ''">
347 <xsl:value-of select='wl:texcommand(name($verse-type))' />
349 <xsl:otherwise>wers</xsl:otherwise>
352 <xsl:if test="string($verse-content/@typ)">
353 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
355 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
359 <!-- ================================================ -->
360 <!-- = INLINE TAGS = -->
361 <!-- = (contain other inline tags and special tags) = -->
362 <!-- ================================================ -->
364 <xsl:template mode="inline"
365 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
367 <xsl:attribute name="name">
368 <xsl:value-of select="wl:texcommand(name())" />
370 <parm><xsl:apply-templates mode="inline"/></parm>
376 <xsl:template match="tytul_dziela" mode="inline">
377 <cmd name="tytuldziela"><parm>
378 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
384 <!-- ============================================== -->
385 <!-- = STANDALONE TAGS = -->
386 <!-- = (cannot contain any other tags) = -->
387 <!-- ============================================== -->
389 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
391 <xsl:attribute name="name">
392 <xsl:value-of select="wl:texcommand(name())" />
398 <!-- ================ -->
399 <!-- = SPECIAL TAGS = -->
400 <!-- ================ -->
404 <xsl:template match="begin|end|motyw">
405 <xsl:apply-templates select='.' mode="inline" />
408 <xsl:template match="begin" mode="inline" />
409 <xsl:template match="end" mode="inline" />
411 <xsl:template match="motyw" mode="inline">
413 <xsl:if test="@moved">
414 <opt name="moved"><xsl:value-of select="@moved" /></opt>
416 <parm><xsl:apply-templates mode="inline" /></parm>
420 <xsl:template name="authors">
421 <xsl:for-each select=".//dc:creator_parsed">
422 <xsl:if test="position() != 1">, </xsl:if>
423 <xsl:apply-templates mode="inline" />
427 <xsl:template name="editors">
428 <xsl:if test="@editors">
429 <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
430 <xsl:value-of select="@editors" />
431 <xsl:text>.</xsl:text>
435 <xsl:template name="translators">
436 <xsl:if test=".//dc:contributor.translator_parsed">
437 <cmd name='translator'><parm>
438 <xsl:for-each select=".//dc:contributor.translator_parsed">
439 <xsl:if test="position() != 1">, </xsl:if>
440 <xsl:apply-templates mode="inline" />
446 <xsl:template match="data-sponsor" mode="sponsor">
447 <cmd name="par"><parm>
449 <xsl:when test="@src">
450 \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
453 <xsl:value-of select="@name" />
459 <xsl:template match="mat" mode="inline">
461 <xsl:text>$</xsl:text>
462 <xsl:value-of select="wl:mathml_latex(.)" />
463 <xsl:text>$</xsl:text>
467 <xsl:template match="mat">
469 <xsl:text>$$</xsl:text>
470 <xsl:value-of select="wl:mathml_latex(.)" />
471 <xsl:text>$$</xsl:text>
475 <xsl:template match="tabela|tabelka">
477 <cmd name="vspace"><parm>1em</parm></cmd>
478 <group><cmd name="raggedright" />
479 <xsl:element name="env">
480 <xsl:attribute name="name">
482 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
483 <xsl:otherwise>tabu</xsl:otherwise>
485 </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
486 <!--parm><cmd name="textwidth"/></parm-->
487 <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
489 <xsl:when test="@ramka='1' or @ramki='1'">
491 <xsl:apply-templates mode="wiersze-ramki"/>
494 <xsl:apply-templates/>
499 <cmd name="vspace"><parm>1em</parm></cmd>
501 <xsl:template match="wiersz" mode="wiersze-ramki">
502 <xsl:apply-templates />
503 <spec cat="esc"/><spec cat="esc"/>
504 <cmd name="hline" gr="0" />
506 <xsl:template match="wiersz">
507 <xsl:apply-templates />
508 <spec cat="esc"/><spec cat="esc"/>
510 <xsl:template match="kol">
511 <xsl:apply-templates mode="inline"/>
512 <xsl:if test="position() < last()">
518 <!-- ============== -->
519 <!-- = ADDED TAGS = -->
520 <!-- ============== -->
523 <xsl:template match="dywiz" mode="inline">
527 <xsl:template match="nbsp" mode="inline">
531 <xsl:template match="alien" mode="inline">
534 <xsl:apply-templates mode="inline" />
538 <!-- ================ -->
539 <!-- = IGNORED TAGS = -->
540 <!-- ================ -->
541 <xsl:template match="extra|uwaga" />
542 <xsl:template match="extra|uwaga" mode="inline" />
544 <xsl:template match="nota_red" />
545 <xsl:template match="abstrakt" />
550 <xsl:template match="text()" />
551 <xsl:template match="text()" mode="inline">
552 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
553 <xsl:text> </xsl:text>
556 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
558 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
559 <xsl:text> </xsl:text>