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=32]{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 <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" />
92 <!--xsl:if test="@data-cover-by">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 udostępniony na licencji\\
159 \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
163 <xsl:if test=".//dc:source">
164 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
167 \def\description{\raggedright <TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
172 <!-- ============== -->
173 <!-- = BOOK TITLE = -->
174 <!-- = (from DC) = -->
175 <!-- ============== -->
177 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
178 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
181 <xsl:template match="rdf:RDF" mode="dctitle">
182 <cmd name="nazwapodutworu"><parm>
183 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
187 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
188 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
191 <xsl:template match="rdf:RDF" mode="firstdctitle">
192 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
193 <cmd name="nazwautworu"><parm>
194 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
196 <cmd name="translatorsline" />
200 <!-- ============================================================================== -->
201 <!-- = MASTER TAG = -->
202 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
203 <!-- ============================================================================== -->
204 <!-- ==================================================================================== -->
205 <!-- = BLOCK TAGS = -->
206 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
207 <!-- ==================================================================================== -->
210 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
212 <xsl:attribute name="name">
213 <xsl:value-of select="wl:texcommand(name())" />
215 <parm><xsl:apply-templates/></parm>
219 <xsl:template match="lista_osob">
220 <cmd name="listaosob">
221 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
222 <parm><xsl:apply-templates select="lista_osoba" /></parm>
226 <xsl:template match="kwestia">
228 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
233 <xsl:template match="tabela|tabelka">
235 <cmd name="vspace"><parm>1em</parm></cmd>
236 <group><cmd name="raggedright" />
237 <env name="longtabu"> to <TeXML escape="0">\textwidth </TeXML>
238 <!--parm><cmd name="textwidth"/></parm-->
239 <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
241 <xsl:when test="@ramka='1' or @ramki='1'">
242 <!--parm><spec cat="vert"/>X[1,l]<spec cat="vert"/>X[1,l]<spec cat="vert"/>X[1,l]<spec cat="vert"/>X[1,l]<spec cat="vert"/>X[1,l]<spec cat="vert"/></parm-->
244 <xsl:apply-templates mode="wiersze-ramki"/>
247 <!--parm>XXXXX</parm-->
248 <xsl:apply-templates/>
253 <cmd name="vspace"><parm>1em</parm></cmd>
255 <xsl:template match="wiersz" mode="wiersze-ramki">
256 <xsl:apply-templates />
257 <spec cat="esc"/><spec cat="esc"/>
258 <cmd name="hline" gr="0" />
260 <xsl:template match="wiersz">
261 <xsl:apply-templates />
262 <spec cat="esc"/><spec cat="esc"/>
265 <xsl:template match="kol">
266 <xsl:apply-templates mode="inline"/>
267 <xsl:if test="position() < last()">
272 <xsl:template match="punkt">
273 <cmd name="punkt"><parm>
275 <xsl:when test=".//akap">
276 <xsl:apply-templates />
279 <xsl:apply-templates mode="inline"/>
284 <xsl:template match="lista">
285 <xsl:if test="@typ='num'">
286 <cmd name="listanum">
287 <parm><xsl:apply-templates /></parm>
290 <xsl:if test="@typ='punkt'">
291 <cmd name="listapunkt">
292 <parm><xsl:apply-templates /></parm>
297 <xsl:template match="ilustr">
299 <parm><xsl:value-of select="@src" /></parm>
300 <parm><xsl:value-of select="@alt" /></parm>
304 <!-- ========================================== -->
305 <!-- = PARAGRAPH TAGS = -->
306 <!-- = (can contain inline and special tags) = -->
307 <!-- ========================================== -->
309 <!-- only in root -->
311 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
314 <xsl:attribute name="name">
315 <xsl:value-of select="wl:texcommand(name())" />
317 <parm><xsl:apply-templates mode="inline"/></parm>
323 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">
325 <xsl:attribute name="name">
326 <xsl:value-of select="wl:texcommand(name())" />
328 <parm><xsl:apply-templates mode="inline"/></parm>
332 <xsl:template match="strofa">
333 <cmd name="strofa"><parm>
335 <xsl:when test="count(br) > 0">
336 <xsl:call-template name="verse">
337 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
338 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
340 <xsl:for-each select="br">
341 <TeXML escape="0">\\{}</TeXML>
342 <!-- Each BR tag "consumes" text after it -->
343 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
344 <xsl:call-template name="verse">
345 <xsl:with-param name="verse-content"
346 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
347 <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]" />
352 <xsl:call-template name="verse">
353 <xsl:with-param name="verse-content" select="text() | node()" />
354 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
362 <xsl:template name="verse">
363 <xsl:param name="verse-content" />
364 <xsl:param name="verse-type" />
367 <xsl:attribute name="name">
369 <xsl:when test="$verse-type != ''">
370 <xsl:value-of select='wl:texcommand(name($verse-type))' />
372 <xsl:otherwise>wers</xsl:otherwise>
375 <xsl:if test="string($verse-content/@typ)">
376 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
378 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
382 <!-- ================================================ -->
383 <!-- = INLINE TAGS = -->
384 <!-- = (contain other inline tags and special tags) = -->
385 <!-- ================================================ -->
387 <xsl:template mode="inline"
388 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
390 <xsl:attribute name="name">
391 <xsl:value-of select="wl:texcommand(name())" />
393 <parm><xsl:apply-templates mode="inline"/></parm>
397 <xsl:template match="www" mode="inline">
399 <parm><xsl:value-of select="wl:urlquote(text())" /></parm>
400 <parm><cmd name="url"><parm><xsl:value-of select="text()" /></parm></cmd></parm>
406 <xsl:template match="tytul_dziela" mode="inline">
407 <cmd name="tytuldziela"><parm>
408 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
414 <!-- ============================================== -->
415 <!-- = STANDALONE TAGS = -->
416 <!-- = (cannot contain any other tags) = -->
417 <!-- ============================================== -->
419 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
421 <xsl:attribute name="name">
422 <xsl:value-of select="wl:texcommand(name())" />
428 <!-- ================ -->
429 <!-- = SPECIAL TAGS = -->
430 <!-- ================ -->
434 <xsl:template match="begin|end|motyw">
435 <xsl:apply-templates select='.' mode="inline" />
438 <xsl:template match="begin" mode="inline" />
439 <xsl:template match="end" mode="inline" />
441 <xsl:template match="motyw" mode="inline">
443 <xsl:if test="@moved">
444 <opt name="moved"><xsl:value-of select="@moved" /></opt>
446 <parm><xsl:apply-templates mode="inline" /></parm>
450 <xsl:template name="authors">
451 <xsl:for-each select=".//dc:creator_parsed">
452 <xsl:if test="position() != 1">, </xsl:if>
453 <xsl:apply-templates mode="inline" />
457 <xsl:template name="editors">
458 <!--xsl:if test="@editors">
459 <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
460 <xsl:value-of select="@editors" />
461 <xsl:text>.</xsl:text>
463 <xsl:if test=".//dc:contributor.editor_parsed">
464 <cmd name="par"><parm>Redakcja literacka:
465 <xsl:for-each select=".//dc:contributor.editor_parsed">
466 <xsl:if test="position() != 1">, </xsl:if>
467 <xsl:apply-templates mode="inline" />
471 <xsl:if test=".//dc:contributor.technical_editor_parsed">
472 <cmd name="par"><parm>Redakcja techniczna:
473 <xsl:for-each select=".//dc:contributor.technical_editor_parsed">
474 <xsl:if test="position() != 1">, </xsl:if>
475 <xsl:apply-templates mode="inline" />
483 <xsl:template name="translators">
484 <xsl:if test=".//dc:contributor.translator_parsed">
485 <cmd name='translator'><parm>
486 <xsl:for-each select=".//dc:contributor.translator_parsed">
487 <xsl:if test="position() != 1">, </xsl:if>
488 <xsl:apply-templates mode="inline" />
495 <!-- ============== -->
496 <!-- = ADDED TAGS = -->
497 <!-- ============== -->
500 <xsl:template match="dywiz" mode="inline">
504 <xsl:template match="nbsp" mode="inline">
508 <xsl:template match="alien" mode="inline">
511 <xsl:apply-templates mode="inline" />
517 <!-- ================ -->
518 <!-- = IGNORED TAGS = -->
519 <!-- ================ -->
520 <xsl:template match="extra|uwaga" />
521 <xsl:template match="extra|uwaga" mode="inline" />
523 <xsl:template match="nota_red" />
528 <xsl:template match="text()" />
529 <xsl:template match="text()" mode="inline">
530 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
531 <xsl:text> </xsl:text>
534 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
536 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
537 <xsl:text> </xsl:text>