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="nazwapodutworu"><parm>
110 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
114 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
115 <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
118 <xsl:template match="rdf:RDF" mode="firstdctitle">
119 <cmd name="autorutworu"><parm>
120 <xsl:apply-templates select=".//dc:creator_parsed/node()" mode="inline" />
122 <cmd name="nazwautworu"><parm>
123 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
128 <!-- ============================================================================== -->
129 <!-- = MASTER TAG = -->
130 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
131 <!-- ============================================================================== -->
132 <!-- ==================================================================================== -->
133 <!-- = BLOCK TAGS = -->
134 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
135 <!-- ==================================================================================== -->
138 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
140 <xsl:attribute name="name">
141 <xsl:value-of select="wl:texcommand(name())" />
143 <parm><xsl:apply-templates/></parm>
147 <xsl:template match="lista_osob">
148 <cmd name="listaosob">
149 <parm><xsl:apply-templates select="naglowek_listy" /></parm>
150 <parm><xsl:apply-templates select="lista_osoba" /></parm>
154 <xsl:template match="kwestia">
156 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
161 <!-- ========================================== -->
162 <!-- = PARAGRAPH TAGS = -->
163 <!-- = (can contain inline and special tags) = -->
164 <!-- ========================================== -->
166 <!-- only in root -->
167 <xsl:template match="autor_utworu" mode="title">
168 <cmd name="autorutworu"><parm>
169 <xsl:apply-templates mode="inline" />
175 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">
177 <xsl:attribute name="name">
178 <xsl:value-of select="wl:texcommand(name())" />
180 <parm><xsl:apply-templates mode="inline"/></parm>
184 <xsl:template match="strofa">
185 <cmd name="strofa"><parm>
187 <xsl:when test="count(br) > 0">
188 <xsl:call-template name="verse">
189 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
190 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
192 <xsl:for-each select="br">
193 <TeXML escape="0">\\{}</TeXML>
194 <!-- Each BR tag "consumes" text after it -->
195 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
196 <xsl:call-template name="verse">
197 <xsl:with-param name="verse-content"
198 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
199 <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]" />
204 <xsl:call-template name="verse">
205 <xsl:with-param name="verse-content" select="text() | node()" />
206 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
214 <xsl:template name="verse">
215 <xsl:param name="verse-content" />
216 <xsl:param name="verse-type" />
219 <xsl:attribute name="name">
221 <xsl:when test="$verse-type != ''">
222 <xsl:value-of select='wl:texcommand(name($verse-type))' />
224 <xsl:otherwise>wers</xsl:otherwise>
227 <xsl:if test="string($verse-content/@typ)">
228 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
230 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
234 <!-- ================================================ -->
235 <!-- = INLINE TAGS = -->
236 <!-- = (contain other inline tags and special tags) = -->
237 <!-- ================================================ -->
239 <xsl:template mode="inline"
240 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
242 <xsl:attribute name="name">
243 <xsl:value-of select="wl:texcommand(name())" />
245 <parm><xsl:apply-templates mode="inline"/></parm>
251 <xsl:template match="tytul_dziela" mode="inline">
252 <cmd name="tytuldziela"><parm>
253 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
259 <!-- ============================================== -->
260 <!-- = STANDALONE TAGS = -->
261 <!-- = (cannot contain any other tags) = -->
262 <!-- ============================================== -->
264 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
266 <xsl:attribute name="name">
267 <xsl:value-of select="wl:texcommand(name())" />
273 <!-- ================ -->
274 <!-- = SPECIAL TAGS = -->
275 <!-- ================ -->
279 <xsl:template match="begin|end|motyw">
280 <xsl:apply-templates select='.' mode="inline" />
283 <xsl:template match="begin" mode="inline" />
284 <xsl:template match="end" mode="inline" />
286 <xsl:template match="motyw" mode="inline">
288 <xsl:if test="@moved">
289 <opt name="moved"><xsl:value-of select="@moved" /></opt>
291 <parm><xsl:apply-templates mode="inline" /></parm>
296 <!-- ============== -->
297 <!-- = ADDED TAGS = -->
298 <!-- ============== -->
301 <xsl:template match="dywiz" mode="inline">
305 <xsl:template match="nbsp" mode="inline">
309 <!-- ================ -->
310 <!-- = IGNORED TAGS = -->
311 <!-- ================ -->
312 <xsl:template match="extra|uwaga" />
313 <xsl:template match="extra|uwaga" mode="inline" />
315 <xsl:template match="nota_red" />
320 <xsl:template match="text()" />
321 <xsl:template match="text()" mode="inline">
322 <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
323 <xsl:text> </xsl:text>
326 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
328 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
329 <xsl:text> </xsl:text>