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 <!-- ================================================ -->
334 <xsl:strip-space elements="wyroznienie|akap|nota"/>
336 <xsl:template mode="inline"
337 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|punkt|www|nota_red">
339 <xsl:attribute name="name">
340 <xsl:value-of select="wl:texcommand(name())" />
342 <parm><xsl:apply-templates mode="inline"/></parm>
346 <xsl:template mode="inline"
349 <xsl:attribute name="name">
350 <xsl:value-of select="wl:texcommand(name())" />
352 <xsl:apply-templates mode="inline"/>
356 match="wyimek_extra">
358 <xsl:attribute name="name">
359 <xsl:value-of select="wl:texcommand(name())" />
361 <xsl:apply-templates mode="inline"/>
368 <xsl:template match="tytul_dziela" mode="inline">
369 <cmd name="tytuldziela"><parm>
370 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
376 <!-- ============================================== -->
377 <!-- = STANDALONE TAGS = -->
378 <!-- = (cannot contain any other tags) = -->
379 <!-- ============================================== -->
381 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
383 <xsl:attribute name="name">
384 <xsl:value-of select="wl:texcommand(name())" />
389 <xsl:strip-space elements="ilustr"/>
390 <xsl:template match="ilustr">
392 <xsl:attribute name="name">
393 <xsl:value-of select="wl:texcommand(name())" />
396 <opt><TeXML ecape="0"><xsl:value-of select="normalize-space(@opt)" /></TeXML></opt>
398 <parm><TeXML escape="0"><xsl:value-of select="normalize-space(@src)" /></TeXML></parm>
399 <parm><xsl:apply-templates mode="inline" /></parm>
403 <xsl:template match="@*|node()" mode="identity">
405 <xsl:apply-templates select="@*|node()" mode="identity"/>
411 <xsl:template match="dmath">
413 <xsl:apply-templates mode="identity"/>
417 <xsl:template match="math" mode="inline">
419 <xsl:apply-templates mode="identity"/>
423 <xsl:template match="latex">
425 <xsl:for-each select="text()">
426 <xsl:value-of select="normalize-space(.)"/>
431 <xsl:template match="latex" mode="inline">
433 <xsl:for-each select="text()">
434 <xsl:value-of select="normalize-space(.)"/>
440 <xsl:template match="tablewrap">
441 <cmd name="begin"><parm>table</parm><opt>h!</opt></cmd>
442 <xsl:apply-templates select="table"/>
444 <cmd name="caption*"><parm>
445 <xsl:apply-templates select="akap"/>
447 <cmd name="end"><parm>table</parm></cmd>
450 <xsl:template match="table">
451 <xsl:if test="@caption">
453 <cmd name="caption*"><parm>
455 <cmd name="Large"/><xsl:value-of select="@caption"/>
458 <env name="tabularx">
459 <parm><cmd name="textwidth"/></parm>
460 <parm><xsl:value-of select="@spec"/></parm>
461 <xsl:apply-templates />
465 <xsl:template match="r">
466 <xsl:apply-templates />
467 <spec cat="esc"/><spec cat="esc"/>
469 <xsl:template match="c">
470 <cmd name="footnotesize"/>
471 <xsl:apply-templates mode="inline"/>
472 <xsl:if test="position() < last()-1">
476 <xsl:template match="hr">
480 <!-- ================ -->
481 <!-- = SPECIAL TAGS = -->
482 <!-- ================ -->
486 <xsl:template match="begin|end|motyw">
487 <xsl:apply-templates select='.' mode="inline" />
490 <xsl:template match="begin" mode="inline" />
491 <xsl:template match="end" mode="inline" />
493 <xsl:template match="motyw" mode="inline">
495 <xsl:if test="@moved">
496 <opt name="moved"><xsl:value-of select="@moved" /></opt>
498 <parm><xsl:apply-templates mode="inline" /></parm>
502 <xsl:template name="authors">
503 <xsl:for-each select=".//dc:creator_parsed">
504 <xsl:if test="position() != 1">, </xsl:if>
505 <xsl:apply-templates mode="inline" />
509 <xsl:template name="editors">
510 <xsl:if test=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed">
511 <xsl:text>Redakcja techniczna: </xsl:text>
512 <xsl:for-each select=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed[not(.//dc:contributor.editor_parsed/text()=text())]">
513 <!--xsl:sort select="@sortkey" /-->
514 <xsl:if test="position() != 1">, </xsl:if>
515 <xsl:apply-templates mode="inline" />
520 <xsl:template name="translators">
521 <xsl:if test=".//dc:contributor.translator_parsed">
522 <cmd name='translator'><parm>
523 <xsl:for-each select=".//dc:contributor.translator_parsed">
524 <xsl:if test="position() != 1">, </xsl:if>
525 <xsl:apply-templates mode="inline" />
532 <!-- ============== -->
533 <!-- = ADDED TAGS = -->
534 <!-- ============== -->
537 <xsl:template match="dywiz" mode="inline">
541 <xsl:template match="nbsp" mode="inline">
545 <xsl:template match="alien" mode="inline">
548 <xsl:apply-templates mode="inline" />
552 <!-- ================ -->
553 <!-- = IGNORED TAGS = -->
554 <!-- ================ -->
555 <xsl:template match="extra|uwaga" />
556 <xsl:template match="extra|uwaga" mode="inline" />
558 <!-- make it a command: <xsl:template match="nota_red" />-->
564 <xsl:template match="text()" />
565 <xsl:template match="text()" mode="inline">
566 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
567 <xsl:text> </xsl:text>
570 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
572 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
573 <xsl:text> </xsl:text>