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="wl:get('customization_str')"/>]{wl}
20 <xsl:if test="wl:get('has_cover')">
21 \usepackage{makecover}
25 <xsl:when test="wl:get('morefloats') = 'new'">
27 \usepackage[maxfloats=64]{morefloats}
30 <xsl:when test="wl:get('morefloats') = 'old'">
32 \usepackage{morefloats}
35 <xsl:when test="wl:get('morefloats') = 'none'" />
38 \IfFileExists{morefloats.sty}{
39 \usepackage{morefloats}
45 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
46 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
49 <xsl:if test="wl:get('has_cover')">
50 <cmd name="makecover">
51 <parm><xsl:value-of select="210 * wl:get('cover', 'width') div wl:get('cover', 'height')" />mm</parm>
55 <cmd name="maketitle" />
57 <cmd name="tytul"><parm>
59 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
60 <!-- title in master -->
61 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
62 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
63 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
64 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
65 <!-- dc in master or not -->
66 <cmd name="translatorsline" />
69 <!-- look for author title in dc -->
70 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
71 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
75 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
76 <xsl:apply-templates select="utwor" mode="part" />
81 <xsl:if test="wl:get('has_cover') and wl:get('wldoc', 'book_info', 'cover_by')">
82 <!-- FIXME: should be stylable -->
85 <xsl:when test="wl:get('wldoc', 'book_info', 'cover_source')">
86 <cmd name="href"><parm>
87 <xsl:value-of select="wl:get('wldoc', 'book_info', 'cover_source')" />
89 <xsl:value-of select="wl:get('wldoc', 'book_info', 'cover_by')" />
93 <xsl:value-of select="wl:get('wldoc', 'book_info', 'cover_by')" />
99 \def\editors{<TeXML escape="1"><xsl:call-template name="editors" /></TeXML>}
102 <cmd name="editorialsection" />
109 <xsl:template match="utwor" mode="part">
110 <cmd name="tytul"><parm>
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)/nazwa_utworu" mode="title" />
115 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
118 <!-- look for title in dc -->
119 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
120 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
125 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
126 <xsl:apply-templates select="utwor" mode="part" />
129 <!-- =================== -->
130 <!-- = MAIN TITLE PAGE = -->
131 <!-- = (from DC) = -->
132 <!-- =================== -->
134 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
135 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
138 <xsl:template match="rdf:RDF" mode="titlepage">
140 \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
142 \title{<TeXML escape="1"><xsl:apply-templates select=".//dc:title" mode="inline" /></TeXML>}
143 \def\translatorsline{<TeXML escape="1"><xsl:call-template name="translators" /></TeXML>}
145 \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
147 \def\rightsinfo{<TeXML excape="1">
148 <cmd name="rightsinfostr">
149 <xsl:if test=".//dc:rights.license">
150 <opt><xsl:value-of select=".//dc:rights.license" /></opt>
152 <parm><xsl:value-of select=".//dc:rights" /></parm>
156 <!-- FIXME: should be stylable -->
157 \def\sourceinfo{<TeXML excape="1">
158 <xsl:if test=".//dc:source">
159 Tekst opracowany na podstawie: <xsl:apply-templates select=".//dc:source" mode="inline" />
163 \def\description{<TeXML excape="1">
164 <xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
169 <!-- ============== -->
170 <!-- = BOOK TITLE = -->
171 <!-- = (from DC) = -->
172 <!-- ============== -->
174 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
175 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
178 <xsl:template match="rdf:RDF" mode="dctitle">
179 <cmd name="nazwapodutworu"><parm>
180 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
184 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
185 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
188 <xsl:template match="rdf:RDF" mode="firstdctitle">
189 <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
190 <cmd name="nazwautworu"><parm>
191 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
193 <cmd name="translatorsline" />
197 <!-- ============================================================================== -->
198 <!-- = MASTER TAG = -->
199 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
200 <!-- ============================================================================== -->
201 <!-- ==================================================================================== -->
202 <!-- = BLOCK TAGS = -->
203 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
204 <!-- ==================================================================================== -->
207 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
209 <xsl:attribute name="name">
210 <xsl:value-of select="wl:texcommand(name())" />
212 <parm><xsl:apply-templates/></parm>
216 <xsl:template match="lista_osob">
217 <cmd name="listaosob">
218 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
219 <parm><xsl:apply-templates select="lista_osoba" /></parm>
223 <xsl:template match="kwestia">
225 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
230 <!-- ========================================== -->
231 <!-- = PARAGRAPH TAGS = -->
232 <!-- = (can contain inline and special tags) = -->
233 <!-- ========================================== -->
235 <!-- only in root -->
237 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
240 <xsl:attribute name="name">
241 <xsl:value-of select="wl:texcommand(name())" />
243 <parm><xsl:apply-templates mode="inline"/></parm>
249 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">
251 <xsl:attribute name="name">
252 <xsl:value-of select="wl:texcommand(name())" />
254 <parm><xsl:apply-templates mode="inline"/></parm>
258 <xsl:template match="strofa">
259 <cmd name="strofa"><parm>
261 <xsl:when test="count(br) > 0">
262 <xsl:call-template name="verse">
263 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
264 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
266 <xsl:for-each select="br">
267 <TeXML escape="0">\\{}</TeXML>
268 <!-- Each BR tag "consumes" text after it -->
269 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
270 <xsl:call-template name="verse">
271 <xsl:with-param name="verse-content"
272 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
273 <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]" />
278 <xsl:call-template name="verse">
279 <xsl:with-param name="verse-content" select="text() | node()" />
280 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
288 <xsl:template name="verse">
289 <xsl:param name="verse-content" />
290 <xsl:param name="verse-type" />
293 <xsl:attribute name="name">
295 <xsl:when test="$verse-type != ''">
296 <xsl:value-of select='wl:texcommand(name($verse-type))' />
298 <xsl:otherwise>wers</xsl:otherwise>
301 <xsl:if test="string($verse-content/@typ)">
302 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
304 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
308 <!-- ================================================ -->
309 <!-- = INLINE TAGS = -->
310 <!-- = (contain other inline tags and special tags) = -->
311 <!-- ================================================ -->
313 <xsl:template mode="inline"
314 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
316 <xsl:attribute name="name">
317 <xsl:value-of select="wl:texcommand(name())" />
319 <parm><xsl:apply-templates mode="inline"/></parm>
325 <xsl:template match="tytul_dziela" mode="inline">
326 <cmd name="tytuldziela"><parm>
327 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
333 <!-- ============================================== -->
334 <!-- = STANDALONE TAGS = -->
335 <!-- = (cannot contain any other tags) = -->
336 <!-- ============================================== -->
338 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
340 <xsl:attribute name="name">
341 <xsl:value-of select="wl:texcommand(name())" />
347 <!-- ================ -->
348 <!-- = SPECIAL TAGS = -->
349 <!-- ================ -->
353 <xsl:template match="begin|end|motyw">
354 <xsl:apply-templates select='.' mode="inline" />
357 <xsl:template match="begin" mode="inline" />
358 <xsl:template match="end" mode="inline" />
360 <xsl:template match="motyw" mode="inline">
362 <xsl:if test="@moved">
363 <opt name="moved"><xsl:value-of select="@moved" /></opt>
365 <parm><xsl:apply-templates mode="inline" /></parm>
369 <xsl:template name="authors">
370 <xsl:for-each select=".//dc:creator_parsed">
371 <xsl:if test="position() != 1">, </xsl:if>
372 <xsl:apply-templates mode="inline" />
376 <xsl:template name="editors">
377 <xsl:if test="@editors">
378 <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
379 <xsl:value-of select="@editors" />
380 <xsl:text>.</xsl:text>
384 <xsl:template name="translators">
385 <xsl:if test=".//dc:contributor.translator_parsed">
386 <cmd name='translator'><parm>
387 <xsl:for-each select=".//dc:contributor.translator_parsed">
388 <xsl:if test="position() != 1">, </xsl:if>
389 <xsl:apply-templates mode="inline" />
396 <!-- ============== -->
397 <!-- = ADDED TAGS = -->
398 <!-- ============== -->
401 <xsl:template match="dywiz" mode="inline">
405 <xsl:template match="nbsp" mode="inline">
409 <xsl:template match="alien" mode="inline">
412 <xsl:apply-templates mode="inline" />
416 <!-- ================ -->
417 <!-- = IGNORED TAGS = -->
418 <!-- ================ -->
419 <xsl:template match="extra|uwaga" />
420 <xsl:template match="extra|uwaga" mode="inline" />
422 <xsl:template match="nota_red" />
427 <xsl:template match="text()" />
428 <xsl:template match="text()" mode="inline">
429 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
430 <xsl:text> </xsl:text>
433 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
435 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
436 <xsl:text> </xsl:text>