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" />
149 \def\enotesize{\normalsize}
155 <cmd name="editorialsection" />
161 <xsl:template match="utwor" mode="part">
162 <cmd name="tytul"><parm>
164 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
165 <!-- title in master -->
166 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="part_title" />
167 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
170 <!-- look for title in dc -->
171 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
172 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
177 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
178 <xsl:apply-templates select="utwor" mode="part" />
181 <!-- =================== -->
182 <!-- = MAIN TITLE PAGE = -->
183 <!-- = (from DC) = -->
184 <!-- =================== -->
186 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
187 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
190 <xsl:template match="rdf:RDF" mode="titlepage">
192 \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
194 \title{<TeXML escape="1"><xsl:apply-templates select=".//dc:title" mode="inline" /></TeXML>}
195 \def\translatorsline{<TeXML escape="1"><xsl:call-template name="translators" /></TeXML>}
197 \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
199 \def\rightsinfo{Ten utwór nie jest objęty majątkowym prawem autorskim i~znajduje się w~domenie
200 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
201 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
202 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
203 te dodatkowe materiały udostępnione są na licencji
204 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
205 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
206 <xsl:if test=".//dc:rights.license">
207 \def\rightsinfo{Ten utwór jest udostępniony na licencji
208 \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
212 <xsl:if test=".//dc:source">
213 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
217 <xsl:if test=".//dc:publisher">
220 <xsl:for-each select=".//dc:publisher/text()">
221 <xsl:value-of select="."/>
222 <xsl:if test="not(position() = last())">, </xsl:if>
227 \def\description{<TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
228 <xsl:if test=".//meta[@id='pdf-id']">
229 <xsl:variable name="isbn" select=".//meta[@id='pdf-id']"/>
230 \def\isbn{ISBN <xsl:value-of select="substring-after($isbn, 'ISBN-')"/>}
236 <!-- ============== -->
237 <!-- = BOOK TITLE = -->
238 <!-- = (from DC) = -->
239 <!-- ============== -->
241 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
242 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
245 <xsl:template match="rdf:RDF" mode="dctitle">
246 <xsl:if test="../../rdf:RDF//use_subauthor">
247 <cmd name="autorpodutworu">
248 <parm><xsl:call-template name="authors" /></parm>
251 <cmd name="nazwanadpodutworu"><parm>
252 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
255 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
259 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
260 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
263 <xsl:template match="rdf:RDF" mode="firstdctitle">
264 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
265 <cmd name="nazwautworu"><parm>
266 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
268 <cmd name="translatorsline" />
272 <!-- ============================================================================== -->
273 <!-- = MASTER TAG = -->
274 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
275 <!-- ============================================================================== -->
276 <!-- ==================================================================================== -->
277 <!-- = BLOCK TAGS = -->
278 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
279 <!-- ==================================================================================== -->
282 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
284 <xsl:attribute name="name">
285 <xsl:value-of select="wl:texcommand(name())" />
287 <parm><xsl:apply-templates/></parm>
291 <xsl:template match="lista_osob">
292 <cmd name="listaosob">
293 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
294 <parm><xsl:apply-templates select="lista_osoba" /></parm>
298 <xsl:template match="kwestia">
300 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
304 <xsl:template match="ilustr">
306 <xsl:when test="@oblew = 'true'">
308 <env name="wrapfigure">
311 <cmd name="includegraphics">
312 <opt>width=<cmd name="linewidth"/></opt>
313 <parm><xsl:value-of select="@src"/></parm>
319 <parm><xsl:value-of select="@src" /></parm>
320 <parm><xsl:value-of select="@alt" /></parm>
326 <!-- ========================================== -->
327 <!-- = PARAGRAPH TAGS = -->
328 <!-- = (can contain inline and special tags) = -->
329 <!-- ========================================== -->
331 <!-- only in root -->
333 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
336 <xsl:attribute name="name">
337 <xsl:value-of select="wl:texcommand(name())" />
339 <parm><xsl:apply-templates mode="inline"/></parm>
343 <xsl:template match="nazwa_utworu" mode="part_title">
344 <xsl:if test="../../rdf:RDF//use_subauthor">
345 <cmd name="autorpodutworu"><parm><xsl:call-template name="authors2"/></parm></cmd>
347 <cmd name="nazwapodutworu">
348 <parm><xsl:apply-templates mode="inline"/></parm>
350 <xsl:call-template name="strip-for-toc" />
357 match="naglowek_osoba|naglowek_podrozdzial|podtytul_podrozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy|srodtytul|podtytul_czesc|podtytul_rozdzial|podtytul_akt|podtytul_scena">
359 <xsl:when test="@inline">
360 <xsl:apply-templates mode="inline"/>
364 <xsl:attribute name="name">
365 <xsl:value-of select="wl:texcommand(name())" />
367 <parm><xsl:apply-templates mode="inline"/></parm>
373 <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
375 <xsl:attribute name="name">
376 <xsl:value-of select="wl:texcommand(name())" />
378 <parm><xsl:apply-templates mode="inline"/></parm>
380 <xsl:call-template name="strip-for-toc" />
385 <xsl:template match="strofa" mode="inline">
386 <env name="minipage">
388 <parm><cmd name="linewidth" /></parm>
389 <parm><xsl:apply-templates select="." /></parm>
393 <xsl:template match="strofa">
394 <cmd name="strofa"><parm>
396 <xsl:when test="count(br) > 0">
397 <xsl:call-template name="verse">
398 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
399 <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]" />
401 <xsl:for-each select="br">
402 <TeXML escape="0">\\{}</TeXML>
403 <!-- Each BR tag "consumes" text after it -->
404 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
405 <xsl:call-template name="verse">
406 <xsl:with-param name="verse-content"
407 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
408 <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]" />
413 <xsl:call-template name="verse">
414 <xsl:with-param name="verse-content" select="text() | node()" />
415 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
423 <xsl:template name="verse">
424 <xsl:param name="verse-content" />
425 <xsl:param name="verse-type" />
428 <xsl:attribute name="name">
430 <xsl:when test="$verse-type != ''">
431 <xsl:value-of select='wl:texcommand(name($verse-type))' />
433 <xsl:otherwise>wers</xsl:otherwise>
436 <xsl:if test="string($verse-content/@typ)">
437 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
439 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
443 <!-- ================================================ -->
444 <!-- = INLINE TAGS = -->
445 <!-- = (contain other inline tags and special tags) = -->
446 <!-- ================================================ -->
449 <xsl:template mode="inline"
450 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
452 <xsl:attribute name="name">
453 <xsl:value-of select="wl:texcommand(name())" />
457 <xsl:when test="@blocks">
458 <xsl:apply-templates/>
461 <xsl:apply-templates mode="inline"/>
470 <xsl:template match="tytul_dziela" mode="inline">
471 <cmd name="tytuldziela"><parm>
472 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
478 <!-- ============================================== -->
479 <!-- = STANDALONE TAGS = -->
480 <!-- = (cannot contain any other tags) = -->
481 <!-- ============================================== -->
483 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
485 <xsl:attribute name="name">
486 <xsl:value-of select="wl:texcommand(name())" />
492 <!-- ================ -->
493 <!-- = SPECIAL TAGS = -->
494 <!-- ================ -->
498 <xsl:template match="begin|end|motyw">
499 <xsl:apply-templates select='.' mode="inline" />
502 <xsl:template match="begin" mode="inline" />
503 <xsl:template match="end" mode="inline" />
505 <xsl:template match="motyw" mode="inline">
507 <xsl:if test="@moved">
508 <opt name="moved"><xsl:value-of select="@moved" /></opt>
510 <parm><xsl:apply-templates mode="inline" /></parm>
514 <xsl:template name="authors">
515 <xsl:for-each select=".//dc:creator_parsed">
516 <xsl:if test="position() != 1">, </xsl:if>
517 <xsl:apply-templates mode="inline" />
521 <xsl:template name="authors2">
522 <xsl:for-each select="../..//dc:creator_parsed">
523 <xsl:if test="position() != 1">, </xsl:if>
524 <xsl:apply-templates mode="inline" />
528 <xsl:template name="editors">
529 <xsl:if test="@editors">
530 <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
531 <xsl:value-of select="@editors" />
532 <xsl:text>.</xsl:text>
536 <xsl:template name="translators">
537 <xsl:if test=".//dc:contributor.translator_parsed">
538 <cmd name='translator'><parm>
539 <xsl:for-each select=".//dc:contributor.translator_parsed">
540 <xsl:if test="position() != 1">, </xsl:if>
541 <xsl:apply-templates mode="inline" />
547 <xsl:template name="strip-for-toc">
548 <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
550 <xsl:when test="name() = 'nbsp'">
551 <xsl:text> </xsl:text>
553 <xsl:when test="name() = 'dywiz'">
554 <xsl:text>-</xsl:text>
556 <xsl:when test="name() = 'alien'">
557 <xsl:apply-templates mode="inline" />
559 <xsl:when test="name() = 'slowo_obce'">
560 <xsl:call-template name="strip-for-toc" />
563 <xsl:value-of select="."/>
569 <xsl:template match="data-sponsor" mode="sponsor">
570 <cmd name="par"><parm>
572 <xsl:when test="@src">
573 \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
576 <xsl:value-of select="@name" />
582 <xsl:template match="mat" mode="inline">
584 <xsl:text>$</xsl:text>
585 <xsl:value-of select="wl:mathml_latex(.)" />
586 <xsl:text>$</xsl:text>
590 <xsl:template match="mat">
592 <xsl:text>$$</xsl:text>
593 <xsl:value-of select="wl:mathml_latex(.)" />
594 <xsl:text>$$</xsl:text>
598 <xsl:template match="tabela|tabelka">
600 <cmd name="vspace"><parm>1em</parm></cmd>
601 <group><cmd name="raggedright" />
602 <xsl:element name="env">
603 <xsl:attribute name="name">
605 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
606 <xsl:otherwise>tabu</xsl:otherwise>
608 </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
609 <!--parm><cmd name="textwidth"/></parm-->
610 <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
612 <xsl:when test="@ramka='1' or @ramki='1'">
614 <xsl:apply-templates mode="wiersze-ramki"/>
617 <xsl:apply-templates/>
622 <cmd name="vspace"><parm>1em</parm></cmd>
624 <xsl:template match="wiersz" mode="wiersze-ramki">
625 <xsl:apply-templates />
626 <spec cat="esc"/><spec cat="esc"/>
627 <cmd name="hline" gr="0" />
629 <xsl:template match="wiersz">
630 <xsl:apply-templates />
631 <spec cat="esc"/><spec cat="esc"/>
633 <xsl:template match="kol">
634 <xsl:apply-templates mode="inline"/>
635 <xsl:if test="position() < last()">
641 <!-- ============== -->
642 <!-- = ADDED TAGS = -->
643 <!-- ============== -->
646 <xsl:template match="dywiz" mode="inline">
650 <xsl:template match="nbsp" mode="inline">
654 <xsl:template match="alien" mode="inline">
657 <xsl:apply-templates mode="inline" />
661 <!-- ================ -->
662 <!-- = IGNORED TAGS = -->
663 <!-- ================ -->
664 <xsl:template match="extra|uwaga" />
665 <xsl:template match="extra|uwaga" mode="inline" />
667 <xsl:template match="nota_red" />
668 <xsl:template match="abstrakt" />
673 <xsl:template match="text()" />
674 <xsl:template match="text()" mode="inline">
675 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
676 <xsl:text> </xsl:text>
679 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
681 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
682 <xsl:text> </xsl:text>