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" />
105 <xsl:template match="utwor" mode="part">
106 <cmd name="newpage" />
107 <cmd name="tytul"><parm>
110 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/motyw" mode="inline"/>
113 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
114 <!-- title in master -->
115 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
116 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
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" />}
147 \let\theauthor\@author
151 \def\translatorsline{<xsl:call-template name="translators" />}
153 \def\bookurl{<xsl:value-of select=".//dc:identifier.url" />}
155 \def\rightsinfo{Ten utwór nie jest chroniony prawem autorskim i~znajduje się w~domenie
156 publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
157 i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
158 (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
159 te dodatkowe materiały udostępnione są na licencji
160 \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
161 Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
162 <xsl:if test=".//dc:rights.license">
163 \def\rightsinfo{Ta książka jest udostpęniona na licencji
164 \href{<xsl:value-of select=".//dc:rights.license" />}{<xsl:value-of select=".//dc:rights" />}.}
168 <xsl:if test=".//dc:source">
169 Tekst opracowany na podstawie: <xsl:apply-templates select=".//dc:source" mode="inline" />
172 \def\description{<xsl:apply-templates select=".//dc:description" mode="inline" />}
173 \def\editors{<xsl:call-template name="editors" />}
178 <!-- ============== -->
179 <!-- = BOOK TITLE = -->
180 <!-- = (from DC) = -->
181 <!-- ============== -->
183 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
184 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
187 <xsl:template match="rdf:RDF" mode="dctitle">
188 <cmd name="nazwapodutworu"><parm>
189 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
193 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
194 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
197 <xsl:template match="rdf:RDF" mode="firstdctitle">
198 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
199 <cmd name="nazwautworu"><parm>
200 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
202 <cmd name="translatorsline" />
206 <!-- ============================================================================== -->
207 <!-- = MASTER TAG = -->
208 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
209 <!-- ============================================================================== -->
210 <!-- ==================================================================================== -->
211 <!-- = BLOCK TAGS = -->
212 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
213 <!-- ==================================================================================== -->
216 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
218 <xsl:attribute name="name">
219 <xsl:value-of select="wl:texcommand(name())" />
221 <parm><xsl:apply-templates/></parm>
225 <xsl:template match="lista_osob">
226 <cmd name="listaosob">
227 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
228 <parm><xsl:apply-templates select="lista_osoba" /></parm>
232 <xsl:template match="kwestia">
234 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
239 <!-- ========================================== -->
240 <!-- = PARAGRAPH TAGS = -->
241 <!-- = (can contain inline and special tags) = -->
242 <!-- ========================================== -->
244 <!-- only in root -->
246 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
249 <xsl:attribute name="name">
250 <xsl:value-of select="wl:texcommand(name())" />
252 <parm><xsl:apply-templates mode="inline"/></parm>
256 <xsl:template match="autor_rozdzialu">
260 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|nota_red">
261 <xsl:if test="name(following-sibling::*[1])='autor_rozdzialu'">
262 <cmd name="autorrozdzialu"><parm><xsl:value-of select="following-sibling::*[1]/text()"/></parm></cmd>
265 <xsl:attribute name="name">
266 <xsl:value-of select="wl:texcommand(name())" />
268 <parm><xsl:apply-templates mode="inline"/></parm>
272 <xsl:template match="strofa">
273 <cmd name="strofa"><parm>
275 <xsl:when test="count(br) > 0">
276 <xsl:call-template name="verse">
277 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
278 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
280 <xsl:for-each select="br">
281 <TeXML escape="0">\\{}</TeXML>
282 <!-- Each BR tag "consumes" text after it -->
283 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
284 <xsl:call-template name="verse">
285 <xsl:with-param name="verse-content"
286 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
287 <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]" />
292 <xsl:call-template name="verse">
293 <xsl:with-param name="verse-content" select="text() | node()" />
294 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
302 <xsl:template match="link">
304 <parm><xsl:value-of select="@url"/></parm>
305 <parm><xsl:apply-templates mode="inline"/></parm>
310 <xsl:template name="verse">
311 <xsl:param name="verse-content" />
312 <xsl:param name="verse-type" />
315 <xsl:attribute name="name">
317 <xsl:when test="$verse-type != ''">
318 <xsl:value-of select='wl:texcommand(name($verse-type))' />
320 <xsl:otherwise>wers</xsl:otherwise>
323 <xsl:if test="string($verse-content/@typ)">
324 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
326 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
330 <!-- ================================================ -->
331 <!-- = INLINE TAGS = -->
332 <!-- = (contain other inline tags and special tags) = -->
333 <!-- ================================================ -->
335 <xsl:strip-space elements="nota|akap|wyroznienie"/>
337 <xsl:template mode="inline"
338 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|punkt|www|nota_red">
340 <xsl:attribute name="name">
341 <xsl:value-of select="wl:texcommand(name())" />
343 <parm><xsl:apply-templates mode="inline"/></parm>
347 <xsl:template mode="inline"
350 <xsl:attribute name="name">
351 <xsl:value-of select="wl:texcommand(name())" />
353 <xsl:apply-templates mode="inline"/>
357 match="wyimek_extra">
359 <xsl:attribute name="name">
360 <xsl:value-of select="wl:texcommand(name())" />
362 <xsl:apply-templates mode="inline"/>
369 <xsl:template match="tytul_dziela" mode="inline">
370 <cmd name="tytuldziela"><parm>
371 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
377 <!-- ============================================== -->
378 <!-- = STANDALONE TAGS = -->
379 <!-- = (cannot contain any other tags) = -->
380 <!-- ============================================== -->
382 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
384 <xsl:attribute name="name">
385 <xsl:value-of select="wl:texcommand(name())" />
390 <xsl:strip-space elements="ilustr"/>
391 <xsl:template match="ilustr">
393 <xsl:attribute name="name">
394 <xsl:value-of select="wl:texcommand(name())" />
397 <opt><TeXML ecape="0"><xsl:value-of select="normalize-space(@opt)" /></TeXML></opt>
399 <parm><TeXML escape="0"><xsl:value-of select="normalize-space(@src)" /></TeXML></parm>
400 <parm><xsl:apply-templates mode="inline" /></parm>
404 <xsl:template match="@*|node()" mode="identity">
406 <xsl:apply-templates select="@*|node()" mode="identity"/>
412 <xsl:template match="dmath">
414 <xsl:apply-templates mode="identity"/>
418 <xsl:template match="math" mode="inline">
420 <xsl:apply-templates mode="identity"/>
424 <xsl:template match="latex">
426 <xsl:for-each select="text()">
427 <xsl:value-of select="normalize-space(.)"/>
432 <xsl:template match="latex" mode="inline">
434 <xsl:for-each select="text()">
435 <xsl:value-of select="normalize-space(.)"/>
441 <xsl:template match="tablewrap">
442 <cmd name="begin"><parm>table</parm><opt>h!</opt></cmd>
443 <xsl:apply-templates select="table"/>
445 <cmd name="caption*"><parm>
446 <xsl:apply-templates select="akap"/>
448 <cmd name="end"><parm>table</parm></cmd>
451 <xsl:template match="table">
452 <xsl:if test="@caption">
454 <cmd name="caption*"><parm>
456 <cmd name="Large"/><xsl:value-of select="@caption"/>
459 <env name="tabularx">
460 <parm><cmd name="textwidth"/></parm>
461 <parm><xsl:value-of select="@spec"/></parm>
462 <xsl:apply-templates />
466 <xsl:template match="r">
467 <xsl:apply-templates />
468 <spec cat="esc"/><spec cat="esc"/>
470 <xsl:template match="c">
471 <cmd name="footnotesize"/>
472 <xsl:apply-templates mode="inline"/>
473 <xsl:if test="position() < last()-1">
477 <xsl:template match="hr">
481 <!-- ================ -->
482 <!-- = SPECIAL TAGS = -->
483 <!-- ================ -->
487 <xsl:template match="begin|end|motyw">
488 <xsl:apply-templates select='.' mode="inline" />
491 <xsl:template match="begin" mode="inline" />
492 <xsl:template match="end" mode="inline" />
494 <xsl:template match="motyw" mode="inline">
496 <xsl:if test="@moved">
497 <opt name="moved"><xsl:value-of select="@moved" /></opt>
499 <parm><xsl:apply-templates mode="inline" /></parm>
503 <xsl:template name="authors">
504 <xsl:for-each select=".//dc:creator_parsed">
505 <xsl:if test="position() != 1">, </xsl:if>
506 <xsl:apply-templates mode="inline" />
510 <xsl:template name="editors">
511 <xsl:if test=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed">
512 <xsl:text>Redakcja techniczna: </xsl:text>
513 <xsl:for-each select=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed[not(.//dc:contributor.editor_parsed/text()=text())]">
514 <!--xsl:sort select="@sortkey" /-->
515 <xsl:if test="position() != 1">, </xsl:if>
516 <xsl:apply-templates mode="inline" />
521 <xsl:template name="translators">
522 <xsl:if test=".//dc:contributor.translator_parsed">
523 <cmd name='translator'><parm>
524 <xsl:for-each select=".//dc:contributor.translator_parsed">
525 <xsl:if test="position() != 1">, </xsl:if>
526 <xsl:apply-templates mode="inline" />
533 <!-- ============== -->
534 <!-- = ADDED TAGS = -->
535 <!-- ============== -->
538 <xsl:template match="dywiz" mode="inline">
542 <xsl:template match="nbsp" mode="inline">
546 <xsl:template match="alien" mode="inline">
549 <xsl:apply-templates mode="inline" />
553 <!-- ================ -->
554 <!-- = IGNORED TAGS = -->
555 <!-- ================ -->
556 <xsl:template match="extra|uwaga" />
557 <xsl:template match="extra|uwaga" mode="inline" />
559 <!-- make it a command: <xsl:template match="nota_red" />-->
565 <xsl:template match="text()" />
566 <xsl:template match="text()" mode="inline">
567 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
568 <xsl:text> </xsl:text>
571 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
573 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
574 <xsl:text> </xsl:text>