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>}
36 <!-- WHAT. THE. FUCK. -->
38 <xsl:when test="@morefloats = 'new'">
40 \usepackage[maxfloats=64]{morefloats}
43 <xsl:when test="@morefloats = 'old'">
45 \usepackage{morefloats}
48 <xsl:when test="@morefloats = 'none'" />
51 \IfFileExists{morefloats.sty}{
52 \usepackage{morefloats}
58 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
59 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
65 <xsl:when test="//dc:contributor">Thank you for your contribution, <xsl:value-of select="//dc:contributor"/>!</xsl:when>
66 <xsl:otherwise>Thank you for all your contributions!</xsl:otherwise>
70 <!-- XXX fix this not to hardcode width -->
71 <!--<xsl:if test="@data-cover-width">
72 <cmd name="makecover">
74 <parm><xsl:value-of select="210 * @data-cover-height div @data-cover-width" />mm</parm>
77 <cmd name="makecover" />
78 <cmd name="maketitle" />
82 <xsl:if test="@data-cover-by">Obraz na okładce:
84 <xsl:when test="@data-cover-source">
85 \href{\datacoversource}{\datacoverby}.
95 <cmd name="editorialsection" />
96 <cmd name="spistresci" />
98 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
99 <xsl:apply-templates select="utwor" mode="part" />
104 <xsl:template match="utwor" mode="part">
105 <cmd name="newpage" />
106 <cmd name="tytul"><parm>
109 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/motyw" mode="inline"/>
112 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
113 <!-- title in master -->
114 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
115 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
116 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
117 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
120 <!-- look for title in dc -->
121 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
122 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
127 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
128 <xsl:apply-templates select="utwor" mode="part" />
131 <!-- =================== -->
132 <!-- = MAIN TITLE PAGE = -->
133 <!-- = (from DC) = -->
134 <!-- =================== -->
136 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
137 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
140 <xsl:template match="rdf:RDF" mode="titlepage">
142 \def\authors{<xsl:call-template name="authors" />}
144 \title{<xsl:apply-templates select=".//dc:title" mode="inline" />}
146 \let\theauthor\@author
150 \def\translatorsline{<xsl:call-template name="translators" />}
152 \def\bookurl{<xsl:value-of select=".//dc:identifier.url" />}
154 \def\rightsinfo{Ten utwór nie jest chroniony prawem autorskim i~znajduje się w~domenie
155 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
156 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
157 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
158 te dodatkowe materiały udostępnione są na licencji
159 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
160 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
161 <xsl:if test=".//dc:rights.license">
162 \def\rightsinfo{Ta książka jest udostpęniona na licencji
163 \href{<xsl:value-of select=".//dc:rights.license" />}{<xsl:value-of select=".//dc:rights" />}.}
167 <xsl:if test=".//dc:source">
168 Tekst opracowany na podstawie: <xsl:apply-templates select=".//dc:source" mode="inline" />
171 \def\description{<xsl:apply-templates select=".//dc:description" mode="inline" />}
172 \def\editors{<xsl:call-template name="editors" />}
177 <!-- ============== -->
178 <!-- = BOOK TITLE = -->
179 <!-- = (from DC) = -->
180 <!-- ============== -->
182 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
183 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
186 <xsl:template match="rdf:RDF" mode="dctitle">
187 <cmd name="nazwapodutworu"><parm>
188 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
192 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
193 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
196 <xsl:template match="rdf:RDF" mode="firstdctitle">
197 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
198 <cmd name="nazwautworu"><parm>
199 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
201 <cmd name="translatorsline" />
205 <!-- ============================================================================== -->
206 <!-- = MASTER TAG = -->
207 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
208 <!-- ============================================================================== -->
209 <!-- ==================================================================================== -->
210 <!-- = BLOCK TAGS = -->
211 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
212 <!-- ==================================================================================== -->
215 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
217 <xsl:attribute name="name">
218 <xsl:value-of select="wl:texcommand(name())" />
220 <parm><xsl:apply-templates/></parm>
224 <xsl:template match="lista_osob">
225 <cmd name="listaosob">
226 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
227 <parm><xsl:apply-templates select="lista_osoba" /></parm>
231 <xsl:template match="kwestia">
233 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
238 <!-- ========================================== -->
239 <!-- = PARAGRAPH TAGS = -->
240 <!-- = (can contain inline and special tags) = -->
241 <!-- ========================================== -->
243 <!-- only in root -->
245 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
248 <xsl:attribute name="name">
249 <xsl:value-of select="wl:texcommand(name())" />
251 <parm><xsl:apply-templates mode="inline"/></parm>
255 <xsl:template match="autor_rozdzialu">
259 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|lista">
260 <xsl:if test="name(following-sibling::*[1])='autor_rozdzialu'">
261 <cmd name="autorrozdzialu"><parm><xsl:value-of select="following-sibling::*[1]/text()"/></parm></cmd>
264 <xsl:attribute name="name">
265 <xsl:value-of select="wl:texcommand(name())" />
267 <parm><xsl:apply-templates mode="inline"/></parm>
271 <xsl:template match="strofa">
272 <cmd name="strofa"><parm>
274 <xsl:when test="count(br) > 0">
275 <xsl:call-template name="verse">
276 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
277 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
279 <xsl:for-each select="br">
280 <TeXML escape="0">\\{}</TeXML>
281 <!-- Each BR tag "consumes" text after it -->
282 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
283 <xsl:call-template name="verse">
284 <xsl:with-param name="verse-content"
285 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
286 <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]" />
291 <xsl:call-template name="verse">
292 <xsl:with-param name="verse-content" select="text() | node()" />
293 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
301 <xsl:template match="link">
303 <parm><xsl:value-of select="@url"/></parm>
304 <parm><xsl:apply-templates mode="inline"/></parm>
309 <xsl:template name="verse">
310 <xsl:param name="verse-content" />
311 <xsl:param name="verse-type" />
314 <xsl:attribute name="name">
316 <xsl:when test="$verse-type != ''">
317 <xsl:value-of select='wl:texcommand(name($verse-type))' />
319 <xsl:otherwise>wers</xsl:otherwise>
322 <xsl:if test="string($verse-content/@typ)">
323 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
325 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
329 <!-- ================================================ -->
330 <!-- = INLINE TAGS = -->
331 <!-- = (contain other inline tags and special tags) = -->
332 <!-- ================================================ -->
334 <xsl:template mode="inline"
335 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|punkt|www">
337 <xsl:attribute name="name">
338 <xsl:value-of select="wl:texcommand(name())" />
340 <parm><xsl:apply-templates mode="inline"/></parm>
344 <xsl:template mode="inline"
347 <xsl:attribute name="name">
348 <xsl:value-of select="wl:texcommand(name())" />
350 <xsl:apply-templates mode="inline"/>
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())" />
385 <opt><TeXML ecape="0"><xsl:value-of select="normalize-space(@opt)" /></TeXML></opt>
387 <parm><TeXML escape="0"><xsl:value-of select="normalize-space(@src)" /></TeXML></parm>
388 <parm><xsl:apply-templates mode="inline" /></parm>
392 <xsl:template match="@*|node()" mode="identity">
394 <xsl:apply-templates select="@*|node()" mode="identity"/>
400 <xsl:template match="dmath">
402 <xsl:apply-templates mode="identity"/>
406 <xsl:template match="math" mode="inline">
408 <xsl:apply-templates mode="identity"/>
412 <xsl:template match="latex">
414 <xsl:for-each select="text()">
415 <xsl:value-of select="normalize-space(.)"/>
420 <xsl:template match="latex" mode="inline">
422 <xsl:for-each select="text()">
423 <xsl:value-of select="normalize-space(.)"/>
429 <xsl:template match="tablewrap">
430 <cmd name="begin"><parm>table</parm><opt>h!</opt></cmd>
431 <xsl:apply-templates select="table"/>
433 <cmd name="caption*"><parm>
434 <xsl:apply-templates select="akap"/>
436 <cmd name="end"><parm>table</parm></cmd>
439 <xsl:template match="table">
440 <xsl:if test="@caption">
442 <cmd name="caption*"><parm>
444 <cmd name="Large"/><xsl:value-of select="@caption"/>
447 <env name="tabularx">
448 <parm><cmd name="textwidth"/></parm>
449 <parm><xsl:value-of select="@spec"/></parm>
450 <xsl:apply-templates />
454 <xsl:template match="r">
455 <xsl:apply-templates />
456 <spec cat="esc"/><spec cat="esc"/>
458 <xsl:template match="c">
459 <cmd name="footnotesize"/>
460 <xsl:apply-templates mode="inline"/>
461 <xsl:if test="position() < last()-1">
465 <xsl:template match="hr">
469 <!-- ================ -->
470 <!-- = SPECIAL TAGS = -->
471 <!-- ================ -->
475 <xsl:template match="begin|end|motyw">
476 <xsl:apply-templates select='.' mode="inline" />
479 <xsl:template match="begin" mode="inline" />
480 <xsl:template match="end" mode="inline" />
482 <xsl:template match="motyw" mode="inline">
484 <xsl:if test="@moved">
485 <opt name="moved"><xsl:value-of select="@moved" /></opt>
487 <parm><xsl:apply-templates mode="inline" /></parm>
491 <xsl:template name="authors">
492 <xsl:for-each select=".//dc:creator_parsed">
493 <xsl:if test="position() != 1">, </xsl:if>
494 <xsl:apply-templates mode="inline" />
498 <xsl:template name="editors">
499 <xsl:if test=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed">
500 <xsl:text>Redakcja techniczna: </xsl:text>
501 <xsl:for-each select=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed[not(.//dc:contributor.editor_parsed/text()=text())]">
502 <!--xsl:sort select="@sortkey" /-->
503 <xsl:if test="position() != 1">, </xsl:if>
504 <xsl:apply-templates mode="inline" />
509 <xsl:template name="translators">
510 <xsl:if test=".//dc:contributor.translator_parsed">
511 <cmd name='translator'><parm>
512 <xsl:for-each select=".//dc:contributor.translator_parsed">
513 <xsl:if test="position() != 1">, </xsl:if>
514 <xsl:apply-templates mode="inline" />
521 <!-- ============== -->
522 <!-- = ADDED TAGS = -->
523 <!-- ============== -->
526 <xsl:template match="dywiz" mode="inline">
530 <xsl:template match="nbsp" mode="inline">
534 <xsl:template match="alien" mode="inline">
537 <xsl:apply-templates mode="inline" />
541 <!-- ================ -->
542 <!-- = IGNORED TAGS = -->
543 <!-- ================ -->
544 <xsl:template match="extra|uwaga" />
545 <xsl:template match="extra|uwaga" mode="inline" />
547 <xsl:template match="nota_red" />
552 <xsl:template match="text()" />
553 <xsl:template match="text()" mode="inline">
554 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
555 <xsl:text> </xsl:text>
558 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
560 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
561 <xsl:text> </xsl:text>