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}
22 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
23 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
26 <cmd name="maketitle" />
29 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
30 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
31 <!-- title in master -->
34 <!-- look for author title in dc -->
35 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
36 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
39 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
40 <xsl:apply-templates select="utwor" mode="part" />
45 <xsl:template match="utwor" mode="part">
46 <!-- title for empty dc -->
48 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
49 <!-- title in master -->
52 <!-- look for title in dc -->
53 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
54 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
58 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
59 <xsl:apply-templates select="utwor" mode="part" />
62 <!-- =================== -->
63 <!-- = MAIN TITLE PAGE = -->
64 <!-- = (from DC) = -->
65 <!-- =================== -->
67 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
68 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
71 <xsl:template match="rdf:RDF" mode="titlepage">
72 <cmd name='title'><parm>
73 <xsl:value-of select=".//dc:title/text()" />
75 <cmd name='author'><parm>
76 <xsl:value-of select="wl:person_name(.//dc:creator/text())" />
81 <!-- ============== -->
82 <!-- = BOOK TITLE = -->
83 <!-- = (from DC) = -->
84 <!-- ============== -->
86 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
87 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
90 <xsl:template match="rdf:RDF" mode="dctitle">
91 <cmd name="section*"><parm>
92 <xsl:value-of select=".//dc:title/text()" />
97 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
98 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
101 <xsl:template match="rdf:RDF" mode="firstdctitle">
102 <cmd name="subsection*"><parm>
103 <xsl:value-of select="wl:person_name(.//dc:creator/text())" />
105 <cmd name="section*"><parm>
106 <xsl:value-of select=".//dc:title/text()" />
111 <!-- ============================================================================== -->
112 <!-- = MASTER TAG = -->
113 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
114 <!-- ============================================================================== -->
116 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
117 <xsl:apply-templates />
122 <!-- ==================================================================================== -->
123 <!-- = BLOCK TAGS = -->
124 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
125 <!-- ==================================================================================== -->
126 <xsl:template match="nota">
128 <parm><xsl:apply-templates /></parm>
132 <xsl:template match="lista_osob">
133 <cmd name="par"><parm>
135 <parm><xsl:value-of select="naglowek_listy" /></parm>
138 <xsl:apply-templates select="lista_osoba" />
143 <xsl:template match="dedykacja">
144 <cmd name="hspace"><parm>0.4<cmd name='linewidth' /></parm></cmd>
145 <env name="minipage"><parm>0.6<cmd name='linewidth' /></parm>
147 <xsl:apply-templates />
152 <xsl:template match="kwestia">
154 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
158 <xsl:template match="dlugi_cytat">
159 <env name="quotation">
160 <xsl:apply-templates />
164 <xsl:template match="poezja_cyt">
166 <xsl:apply-templates />
170 <xsl:template match="motto">
172 <xsl:apply-templates mode="inline" />
177 <!-- ========================================== -->
178 <!-- = PARAGRAPH TAGS = -->
179 <!-- = (can contain inline and special tags) = -->
180 <!-- ========================================== -->
182 <!-- only in root -->
183 <xsl:template match="autor_utworu" mode="title">X
184 <cmd name="subsection*"><parm>
185 <xsl:apply-templates mode="inline" />
189 <xsl:template match="nazwa_utworu">
190 <cmd name="section*"><parm>
191 <xsl:apply-templates mode="inline" />
195 <!-- Section headers (included in index)-->
196 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
197 <cmd name="subsection*">
198 <parm><xsl:apply-templates mode="inline" /></parm>
202 <xsl:template match="naglowek_scena|naglowek_rozdzial">
203 <cmd name="subsubsection*">
204 <parm><xsl:apply-templates mode="inline" /></parm>
208 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
209 <cmd name="paragraph*">
210 <parm><xsl:apply-templates mode="inline" /></parm>
214 <!-- Other paragraph tags -->
215 <xsl:template match="miejsce_czas">
216 <cmd name="par"><parm>
218 <parm><xsl:apply-templates mode="inline" /></parm>
223 <xsl:template match="didaskalia">
224 <cmd name="par"><parm>
226 <parm><xsl:apply-templates mode="inline" /></parm>
231 <xsl:template match="lista_osoba">
232 <cmd name="item"><parm>
233 <xsl:apply-templates mode="inline" />
237 <xsl:template match="akap|akap_dialog|akap_cd">
238 <cmd name="par"><parm>
239 <xsl:apply-templates mode="inline" />
243 <xsl:template match="strofa">
244 <cmd name="par"><parm><cmd name="noindent"><parm>
246 <xsl:when test="count(br) > 0">
247 <xsl:call-template name="verse">
248 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
249 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
251 <xsl:for-each select="br">
252 <cmd name="newline" />
253 <!-- Each BR tag "consumes" text after it -->
254 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
255 <xsl:call-template name="verse">
256 <xsl:with-param name="verse-content"
257 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
258 <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]" />
263 <xsl:call-template name="verse">
264 <xsl:with-param name="verse-content" select="text() | node()" />
265 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
269 <cmd name="vspace"><parm>1em</parm></cmd>
270 </parm></cmd></parm></cmd>
274 <xsl:template name="verse">
275 <xsl:param name="verse-content" />
276 <xsl:param name="verse-type" />
277 <xsl:choose><xsl:when test="name($verse-type) = 'wers_akap'"><cmd name="hspace" ><parm><xsl:value-of select="$firet" />pt</parm></cmd></xsl:when>
278 <xsl:when test="name($verse-type) = 'wers_wciety'">
280 <xsl:when test="$verse-content/@typ">
281 <cmd name="hspace" ><parm><xsl:value-of select="$verse-content/@typ" />em</parm></cmd>
284 <cmd name="hspace" ><parm>1em</parm></cmd>
288 <xsl:when test="name($verse-type) = 'wers_cd'">
289 <cmd name="hspace" ><parm>12em</parm></cmd>
292 <xsl:apply-templates select="$verse-content" mode="inline" />
295 <xsl:template match="motto_podpis">
296 <cmd name="hspace"><parm>0.4<cmd name='linewidth' /></parm></cmd>
297 <env name="minipage"><parm>0.6<cmd name='linewidth' /></parm>
299 <xsl:apply-templates mode="inline" />
304 <!-- ================================================ -->
305 <!-- = INLINE TAGS = -->
306 <!-- = (contain other inline tags and special tags) = -->
307 <!-- ================================================ -->
310 <xsl:template match="pa|pe|pr|pt" mode="inline">
311 <cmd name="footnote"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
314 <!-- Other inline tags -->
315 <xsl:template match="mat" mode="inline">
316 <math><xsl:apply-templates mode="inline" /></math>
319 <xsl:template match="didask_tekst" mode="inline">
320 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
323 <xsl:template match="slowo_obce" mode="inline">
324 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
327 <xsl:template match="tytul_dziela" mode="inline">
328 <cmd name="emph"><parm>
329 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
333 <xsl:template match="wyroznienie" mode="inline">
334 <cmd name="emph"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
337 <xsl:template match="osoba" mode="inline">
338 <cmd name="textsc"><parm><xsl:apply-templates mode="inline" /></parm></cmd>
342 <!-- ============================================== -->
343 <!-- = STANDALONE TAGS = -->
344 <!-- = (cannot contain any other tags) = -->
345 <!-- ============================================== -->
346 <xsl:template match="sekcja_swiatlo">
347 <cmd name="hspace"><parm>30pt</parm></cmd>
350 <xsl:template match="sekcja_asterysk">
351 <!-- TODO: padding? -->
352 <cmd name="par"><parm>*</parm></cmd>
355 <xsl:template match="separator_linia">
361 <!-- ================ -->
362 <!-- = SPECIAL TAGS = -->
363 <!-- ================ -->
367 <xsl:template match="begin" mode="inline">
368 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
369 <!--cmd name="mbox" />
370 <cmd name="marginpar">
371 <parm><cmd name="raggedright"><parm>
372 <cmd name="hspace"><parm>0pt</parm></cmd>
373 <cmd name="footnotesize"><parm>
374 <cmd name="color"><parm>theme-gray</parm><parm>
375 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
382 <xsl:template match="begin|end">
383 <xsl:apply-templates select='.' mode="inline" />
386 <xsl:template match="end" mode="inline" />
387 <xsl:template match="motyw" mode="inline" />
390 <!-- ============== -->
391 <!-- = ADDED TAGS = -->
392 <!-- ============== -->
395 <xsl:template match="dywiz" mode="inline">
399 <xsl:template match="nbsp" mode="inline">
403 <!-- ================ -->
404 <!-- = IGNORED TAGS = -->
405 <!-- ================ -->
406 <xsl:template match="extra|uwaga" />
407 <xsl:template match="extra|uwaga" mode="inline" />
413 <xsl:template match="text()" />
414 <xsl:template match="text()" mode="inline">
415 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
416 <xsl:text> </xsl:text>
419 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
421 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
422 <xsl:text> </xsl:text>