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[a4paper, oneside, 11pt]{book}
23 <xsl:when test="@old-morefloats">
25 \IfFileExists{morefloats.sty}{
26 \usepackage{morefloats}
32 \usepackage[maxfloats=64]{morefloats}
37 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
38 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
41 <cmd name="maketitle" />
44 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
45 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
46 <!-- title in master -->
49 <!-- look for author title in dc -->
50 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
51 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
54 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
55 <xsl:apply-templates select="utwor" mode="part" />
60 <xsl:template match="utwor" mode="part">
61 <!-- title for empty dc -->
63 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
64 <!-- title in master -->
67 <!-- look for title in dc -->
68 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
69 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
73 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
74 <xsl:apply-templates select="utwor" mode="part" />
77 <!-- =================== -->
78 <!-- = MAIN TITLE PAGE = -->
79 <!-- = (from DC) = -->
80 <!-- =================== -->
82 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
83 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
86 <xsl:template match="rdf:RDF" mode="titlepage">
87 <cmd name='title'><parm>
88 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
90 <cmd name='author'><parm>
91 <xsl:apply-templates select=".//dc:creator_parsed/node()" mode="inline" />
94 \def\sourceinfo{<TeXML escape="1"><xsl:apply-templates select=".//dc:source/node()" mode="inline" /></TeXML>}
99 <!-- ============== -->
100 <!-- = BOOK TITLE = -->
101 <!-- = (from DC) = -->
102 <!-- ============== -->
104 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
105 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
108 <xsl:template match="rdf:RDF" mode="dctitle">
109 <cmd name="section*"><parm>
110 <xsl:value-of select=".//dc:title/text()" />
115 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
116 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
119 <xsl:template match="rdf:RDF" mode="firstdctitle">
120 <cmd name="subsection*"><parm>
121 <xsl:apply-templates select=".//dc:creator_parsed/node()" mode="inline" />
123 <cmd name="section*"><parm>
124 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
129 <!-- ============================================================================== -->
130 <!-- = MASTER TAG = -->
131 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
132 <!-- ============================================================================== -->
134 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
135 <xsl:apply-templates />
140 <!-- ==================================================================================== -->
141 <!-- = BLOCK TAGS = -->
142 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
143 <!-- ==================================================================================== -->
144 <xsl:template match="nota">
146 <parm><xsl:apply-templates /></parm>
150 <xsl:template match="lista_osob">
151 <cmd name="par"><parm>
153 <parm><xsl:value-of select="naglowek_listy" /></parm>
156 <xsl:apply-templates select="lista_osoba" />
161 <xsl:template match="dedykacja">
163 <env name="flushright">
164 <xsl:apply-templates/>
169 <xsl:template match="kwestia">
171 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
175 <xsl:template match="dlugi_cytat">
176 <env name="quotation">
177 <xsl:apply-templates />
181 <xsl:template match="poezja_cyt">
183 <xsl:apply-templates />
187 <xsl:template match="motto">
189 <xsl:apply-templates mode="inline" />
194 <!-- ========================================== -->
195 <!-- = PARAGRAPH TAGS = -->
196 <!-- = (can contain inline and special tags) = -->
197 <!-- ========================================== -->
199 <!-- only in root -->
200 <xsl:template match="autor_utworu" mode="title">
201 <cmd name="subsection*"><parm>
202 <xsl:apply-templates mode="inline" />
206 <xsl:template match="nazwa_utworu">
207 <cmd name="section*"><parm>
208 <xsl:apply-templates mode="inline" />
212 <!-- Section headers (included in index)-->
213 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
214 <cmd name="subsection*">
215 <parm><xsl:apply-templates mode="inline" /></parm>
219 <xsl:template match="naglowek_scena|naglowek_rozdzial">
220 <cmd name="subsubsection*">
221 <parm><xsl:apply-templates mode="inline" /></parm>
225 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
227 <parm><xsl:apply-templates mode="inline" /></parm>
228 </cmd><cmd name="nopagebreak" />
231 <!-- Other paragraph tags -->
232 <xsl:template match="miejsce_czas">
233 <cmd name="par"><parm>
235 <parm><xsl:apply-templates mode="inline" /></parm>
240 <xsl:template match="didaskalia">
241 <cmd name="par"><parm>
243 <parm><xsl:apply-templates mode="inline" /></parm>
248 <xsl:template match="lista_osoba">
249 <cmd name="item"><parm>
250 <xsl:apply-templates mode="inline" />
254 <xsl:template match="akap|akap_dialog|akap_cd">
255 <cmd name="par"><parm>
256 <xsl:apply-templates mode="inline" />
260 <xsl:template match="strofa">
261 <cmd name="par"><parm><cmd name="noindent"><parm>
263 <xsl:when test="count(br) > 0">
264 <xsl:call-template name="verse">
265 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
266 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
268 <xsl:for-each select="br">
269 <TeXML escape="0">\\{}</TeXML>
270 <!-- Each BR tag "consumes" text after it -->
271 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
272 <xsl:call-template name="verse">
273 <xsl:with-param name="verse-content"
274 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
275 <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]" />
280 <xsl:call-template name="verse">
281 <xsl:with-param name="verse-content" select="text() | node()" />
282 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
286 <cmd name="vspace"><parm>1em</parm></cmd>
287 </parm></cmd></parm></cmd>
291 <xsl:template name="verse">
292 <xsl:param name="verse-content" />
293 <xsl:param name="verse-type" />
294 <xsl:choose><xsl:when test="name($verse-type) = 'wers_akap'"><cmd name="hspace" ><parm>1em</parm></cmd></xsl:when>
295 <xsl:when test="name($verse-type) = 'wers_wciety'">
297 <xsl:when test="string($verse-content/@typ)">
298 <cmd name="hspace" ><parm><xsl:value-of select="$verse-content/@typ" />em</parm></cmd>
301 <cmd name="hspace" ><parm>1em</parm></cmd>
305 <xsl:when test="name($verse-type) = 'wers_cd'">
306 <cmd name="hspace" ><parm>8em</parm></cmd>
309 <xsl:apply-templates select="$verse-content" mode="inline" />
312 <xsl:template match="motto_podpis">
314 <env name="flushright">
315 <xsl:apply-templates mode="inline"/>
320 <!-- ================================================ -->
321 <!-- = INLINE TAGS = -->
322 <!-- = (contain other inline tags and special tags) = -->
323 <!-- ================================================ -->
326 <xsl:template match="pa|pe|pr|pt" mode="inline">
327 <cmd name="footnote"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
330 <!-- Other inline tags -->
331 <xsl:template match="mat" mode="inline">
332 <math><xsl:apply-templates mode="inline" /></math>
335 <xsl:template match="didask_tekst" mode="inline">
336 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
339 <xsl:template match="slowo_obce" mode="inline">
340 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
343 <xsl:template match="tytul_dziela" mode="inline">
344 <cmd name="emph"><parm>
345 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
349 <xsl:template match="wyroznienie" mode="inline">
350 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
353 <xsl:template match="osoba" mode="inline">
354 <cmd name="textsc"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
358 <!-- ============================================== -->
359 <!-- = STANDALONE TAGS = -->
360 <!-- = (cannot contain any other tags) = -->
361 <!-- ============================================== -->
362 <xsl:template match="sekcja_swiatlo">
363 <cmd name="hspace"><parm>30pt</parm></cmd>
366 <xsl:template match="sekcja_asterysk">
367 <!-- TODO: padding? -->
368 <cmd name="par"><parm>*</parm></cmd>
371 <xsl:template match="separator_linia">
377 <!-- ================ -->
378 <!-- = SPECIAL TAGS = -->
379 <!-- ================ -->
383 <xsl:template match="begin|end|motyw">
384 <xsl:apply-templates select='.' mode="inline" />
387 <xsl:template match="begin" mode="inline" />
388 <xsl:template match="end" mode="inline" />
390 <xsl:template match="motyw" mode="inline">
392 <cmd name="marginpar">
394 <cmd name="vspace"><parm>-8pt</parm></cmd>
395 <xsl:if test="@moved">
396 <cmd name="vspace"><parm>-<xsl:value-of select="@moved" /><cmd name="baselineskip" /></parm></cmd>
398 <cmd name="raggedright"><parm>
399 <cmd name="hspace"><parm>0pt</parm></cmd>
400 <cmd name="footnotesize"><parm>
401 <cmd name="color"><parm>theme</parm><parm>
402 <xsl:value-of select="." />
411 <!-- ============== -->
412 <!-- = ADDED TAGS = -->
413 <!-- ============== -->
416 <xsl:template match="dywiz" mode="inline">
420 <xsl:template match="nbsp" mode="inline">
424 <!-- ================ -->
425 <!-- = IGNORED TAGS = -->
426 <!-- ================ -->
427 <xsl:template match="extra|uwaga" />
428 <xsl:template match="extra|uwaga" mode="inline" />
430 <xsl:template match="nota_red" />
435 <xsl:template match="text()" />
436 <xsl:template match="text()" mode="inline">
437 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
438 <xsl:text> </xsl:text>
441 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
443 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
444 <xsl:text> </xsl:text>