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" />
16 <xsl:template match="utwor">
17 <TeXML xmlns="http://getfo.sourceforge.net/texml/ns1">
19 \documentclass[a4paper, oneside, 11pt]{book}
20 \usepackage[MeX]{polski}
21 \usepackage[utf8]{inputenc}
24 \usepackage[bottom]{footmisc}
27 \definecolor{theme-gray}{gray}{.3}
30 \setlength{\marginparsep}{2em}
31 \setlength{\marginparwidth}{8.5em}
32 \setlength{\oddsidemargin}{0pt}
37 <xsl:apply-templates select="rdf:RDF" mode='title' />
38 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='title' />
41 <cmd name="maketitle" />
42 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
43 <xsl:apply-templates select="utwor" mode="part" />
48 <xsl:template match="utwor" mode="part">
50 <xsl:apply-templates select="rdf:RDF" mode='subtitle' />
51 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='subtitle' />
53 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
54 <xsl:apply-templates select="utwor" mode="part" />
58 <!-- ============================================================================== -->
59 <!-- = MASTER TAG = -->
60 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
61 <!-- ============================================================================== -->
63 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="title">
64 <xsl:apply-templates select="rdf:RDF" mode='title' />
67 <xsl:template match="rdf:RDF" mode="title">
70 <cmd name='title'><parm>
71 <xsl:apply-templates select="dzielo_nadrzedne|podtytul" mode="header" />
73 czytanie z tagów nazwa_utworu, autor_utworu
76 <cmd name='title'><parm>
77 <xsl:apply-templates select=".//dc:title" mode="header" />
79 <cmd name='author'><parm>
80 <xsl:apply-templates select=".//dc:author" mode="header" />
84 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="subtitle">
85 <xsl:apply-templates select="rdf:RDF" mode='subtitle' />
88 <xsl:template match="rdf:RDF" mode="subtitle">
89 <cmd name='part*'><parm>
90 <xsl:apply-templates select=".//dc:title" mode="header" />
96 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
97 <xsl:apply-templates />
102 <!-- ==================================================================================== -->
103 <!-- = BLOCK TAGS = -->
104 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
105 <!-- ==================================================================================== -->
106 <xsl:template match="nota">
108 <parm><xsl:apply-templates /></parm>
112 <xsl:template match="lista_osob">
115 <parm><xsl:value-of select="naglowek_listy" /></parm>
118 <xsl:apply-templates select="lista_osoba" />
123 <xsl:template match="dedykacja">
124 <cmd name="raggedleft"><parm>
126 <xsl:apply-templates />
131 <xsl:template match="kwestia">
133 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
137 <xsl:template match="dlugi_cytat">
138 <env name="quotation">
139 <xsl:apply-templates />
143 <xsl:template match="poezja_cyt">
145 <xsl:apply-templates />
149 <xsl:template match="motto">
151 <xsl:apply-templates mode="inline" />
156 <!-- ========================================== -->
157 <!-- = PARAGRAPH TAGS = -->
158 <!-- = (can contain inline and special tags) = -->
159 <!-- ========================================== -->
161 <xsl:template match="autor_utworu" mode="header">
162 <xsl:apply-templates mode="inline" />
165 <xsl:template match="nazwa_utworu" mode="header">
166 <xsl:apply-templates mode="inline" />
169 <xsl:template match="dzielo_nadrzedne" mode="header">
170 <xsl:apply-templates mode="inline" />
173 <xsl:template match="podtytul" mode="header">
174 <xsl:apply-templates mode="inline" />
178 <xsl:template match="nazwa_utworu">
179 <cmd name="pagebreak" />
180 <cmd name="section*"><parm>
181 <xsl:apply-templates mode="inline" />
185 <!-- Section headers (included in index)-->
186 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
187 <cmd name="subsection*">
188 <parm><xsl:apply-templates mode="inline" /></parm>
192 <xsl:template match="naglowek_scena|naglowek_rozdzial">
193 <cmd name="subsubsection*">
194 <parm><xsl:apply-templates mode="inline" /></parm>
198 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
199 <cmd name="paragraph*">
200 <parm><xsl:apply-templates mode="inline" /></parm>
204 <!-- Other paragraph tags -->
205 <xsl:template match="miejsce_czas">
206 <cmd name="par"><parm>
208 <parm><xsl:apply-templates mode="inline" /></parm>
213 <xsl:template match="didaskalia">
214 <cmd name="par"><parm>
216 <parm><xsl:apply-templates mode="inline" /></parm>
221 <xsl:template match="lista_osoba">
222 <cmd name="item"><parm>
223 <xsl:apply-templates mode="inline" />
227 <xsl:template match="akap|akap_dialog|akap_cd">
228 <cmd name="par"><parm>
229 <xsl:apply-templates mode="inline" />
233 <xsl:template match="strofa">
234 <cmd name="par"><parm><cmd name="noindent"><parm>
236 <xsl:when test="count(br) > 0">
237 <xsl:call-template name="verse">
238 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
239 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
241 <xsl:for-each select="br">
242 <cmd name="newline" />
243 <!-- Each BR tag "consumes" text after it -->
244 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
245 <xsl:call-template name="verse">
246 <xsl:with-param name="verse-content"
247 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
248 <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]" />
253 <xsl:call-template name="verse">
254 <xsl:with-param name="verse-content" select="text() | node()" />
255 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
259 <cmd name="vspace"><parm>1em</parm></cmd>
260 </parm></cmd></parm></cmd>
264 <xsl:template name="verse">
265 <xsl:param name="verse-content" />
266 <xsl:param name="verse-type" />
267 <xsl:choose><xsl:when test="name($verse-type) = 'wers_akap'"><cmd name="hspace" ><parm><xsl:value-of select="$firet" />pt</parm></cmd></xsl:when>
268 <xsl:when test="name($verse-type) = 'wers_wciety'">
270 <xsl:when test="$verse-content/@typ">
271 <cmd name="hspace" ><parm><xsl:value-of select="$verse-content/@typ" />em</parm></cmd>
274 <cmd name="hspace" ><parm>1em</parm></cmd>
278 <xsl:when test="name($verse-type) = 'wers_cd'">
279 <cmd name="hspace" ><parm>12em</parm></cmd>
282 <xsl:apply-templates select="$verse-content" mode="inline" />
285 <xsl:template match="motto_podpis">
286 <cmd name="raggedleft"><parm>
287 <xsl:apply-templates mode="inline" />
292 <!-- ================================================ -->
293 <!-- = INLINE TAGS = -->
294 <!-- = (contain other inline tags and special tags) = -->
295 <!-- ================================================ -->
297 <xsl:template match="pa|pe|pr|pt" mode="inline">
298 <cmd name="footnote"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
301 <!-- Other inline tags -->
302 <xsl:template match="mat" mode="inline">
303 <math><xsl:apply-templates mode="inline" /></math>
306 <xsl:template match="didask_tekst" mode="inline">
307 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
310 <xsl:template match="slowo_obce" mode="inline">
311 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
314 <xsl:template match="tytul_dziela" mode="inline">
315 <cmd name="emph"><parm>
316 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
320 <xsl:template match="wyroznienie" mode="inline">
321 <!-- TODO: letterspacing 1pt -->
322 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
325 <xsl:template match="osoba" mode="inline">
326 <cmd name="textsc"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
330 <!-- ============================================== -->
331 <!-- = STANDALONE TAGS = -->
332 <!-- = (cannot contain any other tags) = -->
333 <!-- ============================================== -->
334 <xsl:template match="sekcja_swiatlo">
335 <cmd name="hspace"><parm>30pt</parm></cmd>
338 <xsl:template match="sekcja_asterysk">
339 <!-- TODO: padding? -->
340 <cmd name="par"><parm>*</parm></cmd>
343 <xsl:template match="separator_linia">
349 <!-- ================ -->
350 <!-- = SPECIAL TAGS = -->
351 <!-- ================ -->
355 <xsl:template match="begin" mode="inline">
356 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
358 <cmd name="marginpar">
359 <parm><cmd name="raggedright"><parm>
360 <cmd name="hspace"><parm>0pt</parm></cmd>
361 <cmd name="footnotesize"><parm>
362 <cmd name="color"><parm>theme-gray</parm><parm>
363 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
370 <xsl:template match="begin|end">
371 <xsl:apply-templates select='.' mode="inline" />
374 <xsl:template match="end" mode="inline" />
375 <xsl:template match="motyw" mode="inline" />
378 <!-- ============== -->
379 <!-- = ADDED TAGS = -->
380 <!-- ============== -->
383 <xsl:template match="dywiz" mode="inline">
387 <xsl:template match="nbsp" mode="inline">
391 <!-- ================ -->
392 <!-- = IGNORED TAGS = -->
393 <!-- ================ -->
394 <xsl:template match="extra|uwaga" />
395 <xsl:template match="extra|uwaga" mode="inline" />
401 <xsl:template match="text()" />
402 <xsl:template match="text()" mode="inline">
403 <xsl:value-of select="wl:substitute_entities(.)" />