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"/>]{<xsl:value-of select="@documentclass"/>}
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">Obraz na okładce:
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" />}
162 \let\theauthor\@author
166 \def\translatorsline{<xsl:call-template name="translators" />}
168 \def\bookurl{<xsl:value-of select=".//dc:identifier.url" />}
170 \def\rightsinfo{Ten utwór nie jest chroniony prawem autorskim i~znajduje się w~domenie
171 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
172 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
173 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
174 te dodatkowe materiały udostępnione są na licencji
175 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
176 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
177 <xsl:if test=".//dc:rights.license">
178 \def\rightsinfo{Ta książka jest udostpęniona na licencji
179 \href{<xsl:value-of select=".//dc:rights.license" />}{<xsl:value-of select=".//dc:rights" />}.}
183 <xsl:if test=".//dc:source">
184 Tekst opracowany na podstawie: <xsl:apply-templates select=".//dc:source" mode="inline" />
187 \def\description{<xsl:apply-templates select=".//dc:description" mode="inline" />}
188 \def\editors{<xsl:call-template name="editors" />}
193 <!-- ============== -->
194 <!-- = BOOK TITLE = -->
195 <!-- = (from DC) = -->
196 <!-- ============== -->
198 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
199 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
202 <xsl:template match="rdf:RDF" mode="dctitle">
203 <cmd name="nazwapodutworu"><parm>
204 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
208 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
209 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
212 <xsl:template match="rdf:RDF" mode="firstdctitle">
213 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
214 <cmd name="nazwautworu"><parm>
215 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
217 <cmd name="translatorsline" />
221 <!-- ============================================================================== -->
222 <!-- = MASTER TAG = -->
223 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
224 <!-- ============================================================================== -->
225 <!-- ==================================================================================== -->
226 <!-- = BLOCK TAGS = -->
227 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
228 <!-- ==================================================================================== -->
231 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
233 <xsl:attribute name="name">
234 <xsl:value-of select="wl:texcommand(name())" />
236 <parm><xsl:apply-templates/></parm>
240 <xsl:template match="lista_osob">
241 <cmd name="listaosob">
242 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
243 <parm><xsl:apply-templates select="lista_osoba" /></parm>
247 <xsl:template match="kwestia">
249 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
254 <!-- ========================================== -->
255 <!-- = PARAGRAPH TAGS = -->
256 <!-- = (can contain inline and special tags) = -->
257 <!-- ========================================== -->
259 <!-- only in root -->
261 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
264 <xsl:attribute name="name">
265 <xsl:value-of select="wl:texcommand(name())" />
267 <parm><xsl:apply-templates mode="inline"/></parm>
273 match="naglowek_akt|naglowek_czesc|srodtytul|naglowek_osoba|naglowek_podrozdzial|naglowek_scena|autor_rozdzialu|naglowek_rozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy|lista">
275 <xsl:attribute name="name">
276 <xsl:value-of select="wl:texcommand(name())" />
278 <parm><xsl:apply-templates mode="inline"/></parm>
282 <xsl:template match="strofa">
283 <cmd name="strofa"><parm>
285 <xsl:when test="count(br) > 0">
286 <xsl:call-template name="verse">
287 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
288 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
290 <xsl:for-each select="br">
291 <TeXML escape="0">\\{}</TeXML>
292 <!-- Each BR tag "consumes" text after it -->
293 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
294 <xsl:call-template name="verse">
295 <xsl:with-param name="verse-content"
296 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
297 <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]" />
302 <xsl:call-template name="verse">
303 <xsl:with-param name="verse-content" select="text() | node()" />
304 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
312 <xsl:template match="link">
314 <parm><xsl:value-of select="@url"/></parm>
315 <parm><xsl:apply-templates mode="inline"/></parm>
320 <xsl:template name="verse">
321 <xsl:param name="verse-content" />
322 <xsl:param name="verse-type" />
325 <xsl:attribute name="name">
327 <xsl:when test="$verse-type != ''">
328 <xsl:value-of select='wl:texcommand(name($verse-type))' />
330 <xsl:otherwise>wers</xsl:otherwise>
333 <xsl:if test="string($verse-content/@typ)">
334 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
336 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
340 <!-- ================================================ -->
341 <!-- = INLINE TAGS = -->
342 <!-- = (contain other inline tags and special tags) = -->
343 <!-- ================================================ -->
345 <xsl:template mode="inline"
346 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|punkt|www">
348 <xsl:attribute name="name">
349 <xsl:value-of select="wl:texcommand(name())" />
351 <parm><xsl:apply-templates mode="inline"/></parm>
357 <xsl:template match="tytul_dziela" mode="inline">
358 <cmd name="tytuldziela"><parm>
359 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
365 <!-- ============================================== -->
366 <!-- = STANDALONE TAGS = -->
367 <!-- = (cannot contain any other tags) = -->
368 <!-- ============================================== -->
370 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
372 <xsl:attribute name="name">
373 <xsl:value-of select="wl:texcommand(name())" />
378 <xsl:strip-space elements="ilustr"/>
379 <xsl:template match="ilustr">
381 <xsl:attribute name="name">
382 <xsl:value-of select="wl:texcommand(name())" />
384 <parm><TeXML escape="0"><xsl:value-of select="normalize-space(@src)" /></TeXML></parm>
385 <parm><xsl:apply-templates mode="inline" /></parm>
389 <xsl:template match="@*|node()" mode="identity">
391 <xsl:apply-templates select="@*|node()" mode="identity"/>
397 <xsl:template match="dmath">
399 <xsl:apply-templates mode="identity"/>
403 <xsl:template match="math" mode="inline">
405 <xsl:apply-templates mode="identity"/>
409 <xsl:template match="latex" mode="inline">
411 <xsl:apply-templates select="@*|node()" mode="identity"/>
415 <xsl:template match="tablewrap">
416 <cmd name="begin"><parm>table</parm><opt>h!</opt></cmd>
417 <xsl:apply-templates select="table"/>
419 <cmd name="caption*"><parm>
420 <xsl:apply-templates select="akap"/>
422 <cmd name="end"><parm>table</parm></cmd>
425 <xsl:template match="table">
426 <xsl:if test="@caption">
428 <cmd name="caption*"><parm>
430 <cmd name="Large"/><xsl:value-of select="@caption"/>
433 <env name="tabularx">
434 <parm><cmd name="textwidth"/></parm>
435 <parm><xsl:value-of select="@spec"/></parm>
436 <xsl:apply-templates />
440 <xsl:template match="r">
441 <xsl:apply-templates />
442 <spec cat="esc"/><spec cat="esc"/>
444 <xsl:template match="c">
445 <cmd name="footnotesize"/>
446 <xsl:apply-templates mode="inline"/>
447 <xsl:if test="position() < last()-1">
451 <xsl:template match="hr">
455 <!-- ================ -->
456 <!-- = SPECIAL TAGS = -->
457 <!-- ================ -->
461 <xsl:template match="begin|end|motyw">
462 <xsl:apply-templates select='.' mode="inline" />
465 <xsl:template match="begin" mode="inline" />
466 <xsl:template match="end" mode="inline" />
468 <xsl:template match="motyw" mode="inline">
470 <xsl:if test="@moved">
471 <opt name="moved"><xsl:value-of select="@moved" /></opt>
473 <parm><xsl:apply-templates mode="inline" /></parm>
477 <xsl:template name="authors">
478 <xsl:for-each select=".//dc:creator_parsed">
479 <xsl:if test="position() != 1">, </xsl:if>
480 <xsl:apply-templates mode="inline" />
484 <xsl:template name="editors">
485 <xsl:if test=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed">
486 <xsl:text>Redakcja techniczna: </xsl:text>
487 <xsl:for-each select=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed[not(.//dc:contributor.editor_parsed/text()=text())]">
488 <!--xsl:sort select="@sortkey" /-->
489 <xsl:if test="position() != 1">, </xsl:if>
490 <xsl:apply-templates mode="inline" />
495 <xsl:template name="translators">
496 <xsl:if test=".//dc:contributor.translator_parsed">
497 <cmd name='translator'><parm>
498 <xsl:for-each select=".//dc:contributor.translator_parsed">
499 <xsl:if test="position() != 1">, </xsl:if>
500 <xsl:apply-templates mode="inline" />
507 <!-- ============== -->
508 <!-- = ADDED TAGS = -->
509 <!-- ============== -->
512 <xsl:template match="dywiz" mode="inline">
516 <xsl:template match="nbsp" mode="inline">
520 <xsl:template match="alien" mode="inline">
523 <xsl:apply-templates mode="inline" />
527 <!-- ================ -->
528 <!-- = IGNORED TAGS = -->
529 <!-- ================ -->
530 <xsl:template match="extra|uwaga" />
531 <xsl:template match="extra|uwaga" mode="inline" />
533 <xsl:template match="nota_red" />
538 <xsl:template match="text()" />
539 <xsl:template match="text()" mode="inline">
540 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
541 <xsl:text> </xsl:text>
544 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
546 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
547 <xsl:text> </xsl:text>