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{<xsl:apply-templates select=".//dc:source" mode="inline" />}
101 \def\bookurl{<xsl:value-of select=".//dc:identifier.url" />}
102 \def\rightsinfo{Ten utwór nie jest chroniony prawem autorskim i~znajduje się w~domenie publicznej,
103 co oznacza, że możesz go swobodnie wykorzystywać, publikować i~rozpowszechniać.}
104 <xsl:if test=".//dc:rights.license">
105 \def\rightsinfo{Ten utwór jest udostepniony na licencji
106 \href{<xsl:value-of select=".//dc:rights.license" />}{<xsl:value-of select=".//dc:rights" />}.}
112 <!-- ============== -->
113 <!-- = BOOK TITLE = -->
114 <!-- = (from DC) = -->
115 <!-- ============== -->
117 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
118 <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
121 <xsl:template match="rdf:RDF" mode="dctitle">
122 <cmd name="nazwapodutworu"><parm>
123 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
127 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
128 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
131 <xsl:template match="rdf:RDF" mode="firstdctitle">
132 <cmd name="autorutworu"><parm>
133 <xsl:apply-templates select=".//dc:creator_parsed/node()" mode="inline" />
135 <cmd name="nazwautworu"><parm>
136 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
141 <!-- ============================================================================== -->
142 <!-- = MASTER TAG = -->
143 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
144 <!-- ============================================================================== -->
145 <!-- ==================================================================================== -->
146 <!-- = BLOCK TAGS = -->
147 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
148 <!-- ==================================================================================== -->
151 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
153 <xsl:attribute name="name">
154 <xsl:value-of select="wl:texcommand(name())" />
156 <parm><xsl:apply-templates/></parm>
160 <xsl:template match="lista_osob">
161 <cmd name="listaosob">
162 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
163 <parm><xsl:apply-templates select="lista_osoba" /></parm>
167 <xsl:template match="kwestia">
169 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
174 <!-- ========================================== -->
175 <!-- = PARAGRAPH TAGS = -->
176 <!-- = (can contain inline and special tags) = -->
177 <!-- ========================================== -->
179 <!-- only in root -->
180 <xsl:template match="autor_utworu" mode="title">
181 <cmd name="autorutworu"><parm>
182 <xsl:apply-templates mode="inline" />
188 match="nazwa_utworu|podtytul|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">
190 <xsl:attribute name="name">
191 <xsl:value-of select="wl:texcommand(name())" />
193 <parm><xsl:apply-templates mode="inline"/></parm>
197 <xsl:template match="strofa">
198 <cmd name="strofa"><parm>
200 <xsl:when test="count(br) > 0">
201 <xsl:call-template name="verse">
202 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
203 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
205 <xsl:for-each select="br">
206 <TeXML escape="0">\\{}</TeXML>
207 <!-- Each BR tag "consumes" text after it -->
208 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
209 <xsl:call-template name="verse">
210 <xsl:with-param name="verse-content"
211 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
212 <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]" />
217 <xsl:call-template name="verse">
218 <xsl:with-param name="verse-content" select="text() | node()" />
219 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
227 <xsl:template name="verse">
228 <xsl:param name="verse-content" />
229 <xsl:param name="verse-type" />
232 <xsl:attribute name="name">
234 <xsl:when test="$verse-type != ''">
235 <xsl:value-of select='wl:texcommand(name($verse-type))' />
237 <xsl:otherwise>wers</xsl:otherwise>
240 <xsl:if test="string($verse-content/@typ)">
241 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
243 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
247 <!-- ================================================ -->
248 <!-- = INLINE TAGS = -->
249 <!-- = (contain other inline tags and special tags) = -->
250 <!-- ================================================ -->
252 <xsl:template mode="inline"
253 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
255 <xsl:attribute name="name">
256 <xsl:value-of select="wl:texcommand(name())" />
258 <parm><xsl:apply-templates mode="inline"/></parm>
264 <xsl:template match="tytul_dziela" mode="inline">
265 <cmd name="tytuldziela"><parm>
266 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
272 <!-- ============================================== -->
273 <!-- = STANDALONE TAGS = -->
274 <!-- = (cannot contain any other tags) = -->
275 <!-- ============================================== -->
277 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
279 <xsl:attribute name="name">
280 <xsl:value-of select="wl:texcommand(name())" />
286 <!-- ================ -->
287 <!-- = SPECIAL TAGS = -->
288 <!-- ================ -->
292 <xsl:template match="begin|end|motyw">
293 <xsl:apply-templates select='.' mode="inline" />
296 <xsl:template match="begin" mode="inline" />
297 <xsl:template match="end" mode="inline" />
299 <xsl:template match="motyw" mode="inline">
301 <xsl:if test="@moved">
302 <opt name="moved"><xsl:value-of select="@moved" /></opt>
304 <parm><xsl:apply-templates mode="inline" /></parm>
309 <!-- ============== -->
310 <!-- = ADDED TAGS = -->
311 <!-- ============== -->
314 <xsl:template match="dywiz" mode="inline">
318 <xsl:template match="nbsp" mode="inline">
322 <xsl:template match="alien" mode="inline">
325 <xsl:apply-templates mode="inline" />
329 <!-- ================ -->
330 <!-- = IGNORED TAGS = -->
331 <!-- ================ -->
332 <xsl:template match="extra|uwaga" />
333 <xsl:template match="extra|uwaga" mode="inline" />
335 <xsl:template match="nota_red" />
340 <xsl:template match="text()" />
341 <xsl:template match="text()" mode="inline">
342 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
343 <xsl:text> </xsl:text>
346 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
348 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
349 <xsl:text> </xsl:text>