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="@morefloats = 'new'">
25 \usepackage[maxfloats=64]{morefloats}
28 <xsl:when test="@morefloats = 'old'">
30 \usepackage{morefloats}
33 <xsl:when test="@morefloats = 'none'" />
36 \IfFileExists{morefloats.sty}{
37 \usepackage{morefloats}
43 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
44 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
47 <cmd name="maketitle" />
50 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
51 <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
52 <!-- title in master -->
55 <!-- look for author title in dc -->
56 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
57 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
60 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
61 <xsl:apply-templates select="utwor" mode="part" />
66 <xsl:template match="utwor" mode="part">
67 <!-- title for empty dc -->
69 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
70 <!-- title in master -->
73 <!-- look for title in dc -->
74 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
75 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
79 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
80 <xsl:apply-templates select="utwor" mode="part" />
83 <!-- =================== -->
84 <!-- = MAIN TITLE PAGE = -->
85 <!-- = (from DC) = -->
86 <!-- =================== -->
88 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
89 <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
92 <xsl:template match="rdf:RDF" mode="titlepage">
93 <cmd name='title'><parm>
94 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
96 <cmd name='author'><parm>
97 <xsl:apply-templates select=".//dc:creator_parsed/node()" mode="inline" />
100 \def\sourceinfo{<TeXML escape="1"><xsl:apply-templates select=".//dc:source/node()" mode="inline" /></TeXML>}
105 <!-- ============== -->
106 <!-- = BOOK TITLE = -->
107 <!-- = (from DC) = -->
108 <!-- ============== -->
110 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
111 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
114 <xsl:template match="rdf:RDF" mode="dctitle">
115 <cmd name="nazwapodutworu"><parm>
116 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
120 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
121 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
124 <xsl:template match="rdf:RDF" mode="firstdctitle">
125 <cmd name="autorutworu"><parm>
126 <xsl:apply-templates select=".//dc:creator_parsed/node()" mode="inline" />
128 <cmd name="nazwautworu"><parm>
129 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
134 <!-- ============================================================================== -->
135 <!-- = MASTER TAG = -->
136 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
137 <!-- ============================================================================== -->
138 <!-- ==================================================================================== -->
139 <!-- = BLOCK TAGS = -->
140 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
141 <!-- ==================================================================================== -->
144 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
146 <xsl:attribute name="name">
147 <xsl:value-of select="wl:texcommand(name())" />
149 <parm><xsl:apply-templates/></parm>
153 <xsl:template match="lista_osob">
154 <cmd name="listaosob">
155 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
156 <parm><xsl:apply-templates select="lista_osoba" /></parm>
160 <xsl:template match="kwestia">
162 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
167 <!-- ========================================== -->
168 <!-- = PARAGRAPH TAGS = -->
169 <!-- = (can contain inline and special tags) = -->
170 <!-- ========================================== -->
172 <!-- only in root -->
173 <xsl:template match="autor_utworu" mode="title">
174 <cmd name="autorutworu"><parm>
175 <xsl:apply-templates mode="inline" />
181 match="nazwa_utworu|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">
183 <xsl:attribute name="name">
184 <xsl:value-of select="wl:texcommand(name())" />
186 <parm><xsl:apply-templates mode="inline"/></parm>
190 <xsl:template match="strofa">
191 <cmd name="strofa"><parm>
193 <xsl:when test="count(br) > 0">
194 <xsl:call-template name="verse">
195 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
196 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
198 <xsl:for-each select="br">
199 <TeXML escape="0">\\{}</TeXML>
200 <!-- Each BR tag "consumes" text after it -->
201 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
202 <xsl:call-template name="verse">
203 <xsl:with-param name="verse-content"
204 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
205 <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]" />
210 <xsl:call-template name="verse">
211 <xsl:with-param name="verse-content" select="text() | node()" />
212 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
220 <xsl:template name="verse">
221 <xsl:param name="verse-content" />
222 <xsl:param name="verse-type" />
225 <xsl:attribute name="name">
227 <xsl:when test="$verse-type != ''">
228 <xsl:value-of select='wl:texcommand(name($verse-type))' />
230 <xsl:otherwise>wers</xsl:otherwise>
233 <xsl:if test="string($verse-content/@typ)">
234 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
236 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
240 <!-- ================================================ -->
241 <!-- = INLINE TAGS = -->
242 <!-- = (contain other inline tags and special tags) = -->
243 <!-- ================================================ -->
245 <xsl:template mode="inline"
246 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
248 <xsl:attribute name="name">
249 <xsl:value-of select="wl:texcommand(name())" />
251 <parm><xsl:apply-templates mode="inline"/></parm>
257 <xsl:template match="tytul_dziela" mode="inline">
258 <cmd name="tytuldziela"><parm>
259 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
265 <!-- ============================================== -->
266 <!-- = STANDALONE TAGS = -->
267 <!-- = (cannot contain any other tags) = -->
268 <!-- ============================================== -->
270 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
272 <xsl:attribute name="name">
273 <xsl:value-of select="wl:texcommand(name())" />
279 <!-- ================ -->
280 <!-- = SPECIAL TAGS = -->
281 <!-- ================ -->
285 <xsl:template match="begin|end|motyw">
286 <xsl:apply-templates select='.' mode="inline" />
289 <xsl:template match="begin" mode="inline" />
290 <xsl:template match="end" mode="inline" />
292 <xsl:template match="motyw" mode="inline">
294 <xsl:if test="@moved">
295 <opt name="moved"><xsl:value-of select="@moved" /></opt>
297 <parm><xsl:apply-templates mode="inline" /></parm>
302 <!-- ============== -->
303 <!-- = ADDED TAGS = -->
304 <!-- ============== -->
307 <xsl:template match="dywiz" mode="inline">
311 <xsl:template match="nbsp" mode="inline">
315 <!-- ================ -->
316 <!-- = IGNORED TAGS = -->
317 <!-- ================ -->
318 <xsl:template match="extra|uwaga" />
319 <xsl:template match="extra|uwaga" mode="inline" />
321 <xsl:template match="nota_red" />
326 <xsl:template match="text()" />
327 <xsl:template match="text()" mode="inline">
328 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
329 <xsl:text> </xsl:text>
332 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
334 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
335 <xsl:text> </xsl:text>