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:if test="//utwor//utwor or //naglowek_czesc or //naglowek_akt or //srodtytul or //naglowek_scena or //naglowek_rozdzial">
93 <cmd name="ifshowtoc" />
94 <cmd name="setcounter" >
98 <cmd name="tableofcontents" />
99 <cmd name="clearpage" />
102 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
103 <xsl:apply-templates select="utwor" mode="part" />
106 <xsl:if test="@data-cover-by">
107 \def\coverby{Okładka na podstawie:
109 <xsl:when test="@data-cover-source">
110 \href{\datacoversource}{\datacoverby}
118 \def\editors{<TeXML escape="1"><xsl:call-template name="editors" /></TeXML>}
119 <xsl:if test="@funders">
120 \def\funders{Publikację wsparli i wsparły:
121 <TeXML escape="1"><xsl:value-of select="@funders" /></TeXML>.}
124 <xsl:if test="@sponsor-note|data-sponsor">
128 <xsl:when test="@sponsor-note">
129 <TeXML escape="1"><xsl:value-of select="@sponsor-note" /></TeXML>
132 Sfinansowano ze~środków:
138 <xsl:apply-templates select="data-sponsor" mode="sponsor" />
143 <cmd name="editorialsection" />
149 <xsl:template match="utwor" mode="part">
150 <cmd name="tytul"><parm>
152 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
153 <!-- title in master -->
154 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="part_title" />
155 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
158 <!-- look for title in dc -->
159 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
160 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
165 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
166 <xsl:apply-templates select="utwor" mode="part" />
169 <!-- =================== -->
170 <!-- = MAIN TITLE PAGE = -->
171 <!-- = (from DC) = -->
172 <!-- =================== -->
174 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
175 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
178 <xsl:template match="rdf:RDF" mode="titlepage">
180 \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
182 \title{<TeXML escape="1"><xsl:apply-templates select=".//dc:title" mode="inline" /></TeXML>}
183 \def\translatorsline{<TeXML escape="1"><xsl:call-template name="translators" /></TeXML>}
185 \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
187 \def\rightsinfo{Ten utwór nie jest objęty majątkowym prawem autorskim i~znajduje się w~domenie
188 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
189 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
190 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
191 te dodatkowe materiały udostępnione są na licencji
192 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
193 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
194 <xsl:if test=".//dc:rights.license">
195 \def\rightsinfo{Ten utwór jest udostępniony na licencji
196 \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
200 <xsl:if test=".//dc:source">
201 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
205 <xsl:if test=".//dc:publisher">
208 <xsl:for-each select=".//dc:publisher/text()">
209 <xsl:value-of select="."/>
210 <xsl:if test="not(position() = last())">, </xsl:if>
215 \def\description{<TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
216 <xsl:if test=".//meta[@id='pdf-id']">
217 <xsl:variable name="isbn" select=".//meta[@id='pdf-id']"/>
218 \def\isbn{ISBN <xsl:value-of select="substring-after($isbn, 'ISBN-')"/>}
224 <!-- ============== -->
225 <!-- = BOOK TITLE = -->
226 <!-- = (from DC) = -->
227 <!-- ============== -->
229 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
230 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
233 <xsl:template match="rdf:RDF" mode="dctitle">
234 <xsl:if test="../../rdf:RDF//use_subauthor">
235 <cmd name="autorpodutworu">
236 <parm><xsl:call-template name="authors" /></parm>
239 <cmd name="nazwanadpodutworu"><parm>
240 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
243 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
247 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
248 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
251 <xsl:template match="rdf:RDF" mode="firstdctitle">
252 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
253 <cmd name="nazwautworu"><parm>
254 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
256 <cmd name="translatorsline" />
260 <!-- ============================================================================== -->
261 <!-- = MASTER TAG = -->
262 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
263 <!-- ============================================================================== -->
264 <!-- ==================================================================================== -->
265 <!-- = BLOCK TAGS = -->
266 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
267 <!-- ==================================================================================== -->
270 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
272 <xsl:attribute name="name">
273 <xsl:value-of select="wl:texcommand(name())" />
275 <parm><xsl:apply-templates/></parm>
279 <xsl:template match="lista_osob">
280 <cmd name="listaosob">
281 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
282 <parm><xsl:apply-templates select="lista_osoba" /></parm>
286 <xsl:template match="kwestia">
288 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
292 <xsl:template match="ilustr">
294 <parm><xsl:value-of select="@src" /></parm>
295 <parm><xsl:value-of select="@alt" /></parm>
299 <!-- ========================================== -->
300 <!-- = PARAGRAPH TAGS = -->
301 <!-- = (can contain inline and special tags) = -->
302 <!-- ========================================== -->
304 <!-- only in root -->
306 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
309 <xsl:attribute name="name">
310 <xsl:value-of select="wl:texcommand(name())" />
312 <parm><xsl:apply-templates mode="inline"/></parm>
316 <xsl:template match="nazwa_utworu" mode="part_title">
317 <xsl:if test="../../rdf:RDF//use_subauthor">
318 <cmd name="autorpodutworu"><parm><xsl:call-template name="authors2"/></parm></cmd>
320 <cmd name="nazwapodutworu">
321 <parm><xsl:apply-templates mode="inline"/></parm>
323 <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
325 <xsl:when test="name() = 'nbsp'">
326 <xsl:text> </xsl:text>
328 <xsl:when test="name() = 'dywiz'">
329 <xsl:text>-</xsl:text>
331 <xsl:when test="name() = 'alien' or name() = 'slowo_obce'">
332 <xsl:apply-templates mode="inline" />
335 <xsl:value-of select="."/>
345 match="naglowek_osoba|naglowek_podrozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_diafrlog|akap_cd|motto_podpis|naglowek_listy|srodtytul">
347 <xsl:attribute name="name">
348 <xsl:value-of select="wl:texcommand(name())" />
350 <parm><xsl:apply-templates mode="inline"/></parm>
354 <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
356 <xsl:attribute name="name">
357 <xsl:value-of select="wl:texcommand(name())" />
359 <parm><xsl:apply-templates mode="inline"/></parm>
361 <!-- osobny szablon? -->
362 <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
364 <xsl:when test="name() = 'nbsp'">
365 <xsl:text> </xsl:text>
367 <xsl:when test="name() = 'dywiz'">
368 <xsl:text>-</xsl:text>
370 <xsl:when test="name() = 'alien'">
371 <xsl:apply-templates mode="inline" />
373 <xsl:when test="name() = 'slowo_obce'">
374 <cmd name="slowoobce">
375 <parm><xsl:value-of select="text()"/></parm>
379 <xsl:value-of select="."/>
387 <xsl:template match="strofa" mode="inline">
388 <env name="minipage">
390 <parm><cmd name="linewidth" /></parm>
391 <parm><xsl:apply-templates select="." /></parm>
395 <xsl:template match="strofa">
396 <cmd name="strofa"><parm>
398 <xsl:when test="count(br) > 0">
399 <xsl:call-template name="verse">
400 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
401 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd' or name() = 'wers_do_prawej'][1]" />
403 <xsl:for-each select="br">
404 <TeXML escape="0">\\{}</TeXML>
405 <!-- Each BR tag "consumes" text after it -->
406 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
407 <xsl:call-template name="verse">
408 <xsl:with-param name="verse-content"
409 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
410 <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' or name() = 'wers_do_prawej')][1]" />
415 <xsl:call-template name="verse">
416 <xsl:with-param name="verse-content" select="text() | node()" />
417 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
425 <xsl:template name="verse">
426 <xsl:param name="verse-content" />
427 <xsl:param name="verse-type" />
430 <xsl:attribute name="name">
432 <xsl:when test="$verse-type != ''">
433 <xsl:value-of select='wl:texcommand(name($verse-type))' />
435 <xsl:otherwise>wers</xsl:otherwise>
438 <xsl:if test="string($verse-content/@typ)">
439 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
441 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
445 <!-- ================================================ -->
446 <!-- = INLINE TAGS = -->
447 <!-- = (contain other inline tags and special tags) = -->
448 <!-- ================================================ -->
450 <xsl:template mode="inline"
451 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
453 <xsl:attribute name="name">
454 <xsl:value-of select="wl:texcommand(name())" />
456 <parm><xsl:apply-templates mode="inline"/></parm>
462 <xsl:template match="tytul_dziela" mode="inline">
463 <cmd name="tytuldziela"><parm>
464 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
470 <!-- ============================================== -->
471 <!-- = STANDALONE TAGS = -->
472 <!-- = (cannot contain any other tags) = -->
473 <!-- ============================================== -->
475 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
477 <xsl:attribute name="name">
478 <xsl:value-of select="wl:texcommand(name())" />
484 <!-- ================ -->
485 <!-- = SPECIAL TAGS = -->
486 <!-- ================ -->
490 <xsl:template match="begin|end|motyw">
491 <xsl:apply-templates select='.' mode="inline" />
494 <xsl:template match="begin" mode="inline" />
495 <xsl:template match="end" mode="inline" />
497 <xsl:template match="motyw" mode="inline">
499 <xsl:if test="@moved">
500 <opt name="moved"><xsl:value-of select="@moved" /></opt>
502 <parm><xsl:apply-templates mode="inline" /></parm>
506 <xsl:template name="authors">
507 <xsl:for-each select=".//dc:creator_parsed">
508 <xsl:if test="position() != 1">, </xsl:if>
509 <xsl:apply-templates mode="inline" />
513 <xsl:template name="authors2">
514 <xsl:for-each select="../..//dc:creator_parsed">
515 <xsl:if test="position() != 1">, </xsl:if>
516 <xsl:apply-templates mode="inline" />
520 <xsl:template name="editors">
521 <xsl:if test="@editors">
522 <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
523 <xsl:value-of select="@editors" />
524 <xsl:text>.</xsl:text>
528 <xsl:template name="translators">
529 <xsl:if test=".//dc:contributor.translator_parsed">
530 <cmd name='translator'><parm>
531 <xsl:for-each select=".//dc:contributor.translator_parsed">
532 <xsl:if test="position() != 1">, </xsl:if>
533 <xsl:apply-templates mode="inline" />
539 <xsl:template match="data-sponsor" mode="sponsor">
540 <cmd name="par"><parm>
542 <xsl:when test="@src">
543 \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
546 <xsl:value-of select="@name" />
552 <xsl:template match="mat" mode="inline">
554 <xsl:text>$</xsl:text>
555 <xsl:value-of select="wl:mathml_latex(.)" />
556 <xsl:text>$</xsl:text>
560 <xsl:template match="mat">
562 <xsl:text>$$</xsl:text>
563 <xsl:value-of select="wl:mathml_latex(.)" />
564 <xsl:text>$$</xsl:text>
568 <xsl:template match="tabela|tabelka">
570 <cmd name="vspace"><parm>1em</parm></cmd>
571 <group><cmd name="raggedright" />
572 <xsl:element name="env">
573 <xsl:attribute name="name">
575 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
576 <xsl:otherwise>tabu</xsl:otherwise>
578 </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
579 <!--parm><cmd name="textwidth"/></parm-->
580 <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
582 <xsl:when test="@ramka='1' or @ramki='1'">
584 <xsl:apply-templates mode="wiersze-ramki"/>
587 <xsl:apply-templates/>
592 <cmd name="vspace"><parm>1em</parm></cmd>
594 <xsl:template match="wiersz" mode="wiersze-ramki">
595 <xsl:apply-templates />
596 <spec cat="esc"/><spec cat="esc"/>
597 <cmd name="hline" gr="0" />
599 <xsl:template match="wiersz">
600 <xsl:apply-templates />
601 <spec cat="esc"/><spec cat="esc"/>
603 <xsl:template match="kol">
604 <xsl:apply-templates mode="inline"/>
605 <xsl:if test="position() < last()">
611 <!-- ============== -->
612 <!-- = ADDED TAGS = -->
613 <!-- ============== -->
616 <xsl:template match="dywiz" mode="inline">
620 <xsl:template match="nbsp" mode="inline">
624 <xsl:template match="alien" mode="inline">
627 <xsl:apply-templates mode="inline" />
631 <!-- ================ -->
632 <!-- = IGNORED TAGS = -->
633 <!-- ================ -->
634 <xsl:template match="extra|uwaga" />
635 <xsl:template match="extra|uwaga" mode="inline" />
637 <xsl:template match="nota_red" />
638 <xsl:template match="abstrakt" />
643 <xsl:template match="text()" />
644 <xsl:template match="text()" mode="inline">
645 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
646 <xsl:text> </xsl:text>
649 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
651 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
652 <xsl:text> </xsl:text>