99244eef8412b35ebcbb5f63185788a5f8e85f4d
[librarian.git] / librarian / pdf / wl2tex.xslt
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3
4    This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5    Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6
7 -->
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#" >
12
13 <xsl:output encoding="utf-8" indent="yes" version="2.0" />
14
15 <xsl:template match="utwor">
16     <TeXML xmlns="http://getfo.sourceforge.net/texml/ns1">
17         <TeXML escape="0">
18         \documentclass[<xsl:value-of select="@customizations"/>]{wl}
19
20         <!-- flags and values set on root -->
21
22         \newif\ifflaglessadvertising
23         <xsl:for-each select="@*[starts-with(name(), 'flag-')]">
24             <cmd>
25                 <xsl:attribute name="name"><xsl:value-of select="wl:texcommand(name())" />true</xsl:attribute>
26             </cmd>
27         </xsl:for-each>
28
29         <xsl:for-each select="@*[starts-with(name(), 'data-')]">
30             <TeXML escape="0">
31                 \def\<xsl:value-of select="wl:texcommand(name())" />{<TeXML escape="1"><xsl:value-of select="."/></TeXML>}
32             </TeXML>
33         </xsl:for-each>
34         </TeXML>
35
36         <xsl:choose>
37             <xsl:when test="@morefloats = 'new'">
38                 <TeXML escape="0">
39                     \usepackage[maxfloats=53]{morefloats}
40                 </TeXML>
41             </xsl:when>
42             <xsl:when test="@morefloats = 'old'">
43                 <TeXML escape="0">
44                     \usepackage{morefloats}
45                 </TeXML>
46             </xsl:when>
47             <xsl:when test="@morefloats = 'none'" />
48             <xsl:otherwise>
49                 <TeXML escape="0">
50                     \IfFileExists{morefloats.sty}{
51                         \usepackage{morefloats}
52                     }{}
53                 </TeXML>
54             </xsl:otherwise>
55         </xsl:choose>
56
57         <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
58         <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
59
60         <env name="document">
61             <xsl:if test="@data-cover-width">
62                 <cmd name="makecover">
63                     <parm>210mm</parm>
64                     <parm><xsl:value-of select="210 * @data-cover-height div @data-cover-width" />mm</parm>
65                 </cmd>
66             </xsl:if>
67                 <xsl:if test="@thanks">
68                     <TeXML escape="0">
69                         \def\thanknote{<TeXML escape="1"><xsl:value-of select="@thanks" /></TeXML>}
70                     </TeXML>
71                 </xsl:if>
72             <cmd name="maketitle" />
73
74             <cmd name="tytul"><parm>
75               <xsl:choose>
76                 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
77                     <!-- title in master -->
78                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
79                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
80                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
81                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
82                     <!-- dc in master or not -->
83                     <cmd name="translatorsline" />
84                 </xsl:when>
85                 <xsl:otherwise>
86                     <!-- look for author title in dc -->
87                     <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
88                     <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
89                 </xsl:otherwise>
90               </xsl:choose>
91             </parm></cmd>
92             <xsl:if test="//utwor//utwor or //naglowek_czesc or //naglowek_akt or //srodtytul or //naglowek_scena or //naglowek_rozdzial">
93                 <cmd name="ifshowtoc" />
94                 <cmd name="setcounter" >
95                     <parm>tocdepth</parm>
96                     <parm>3</parm>
97                 </cmd>
98                 <cmd name="tableofcontents" />
99                 <cmd name="clearpage" />
100                 <cmd name="fi" />
101             </xsl:if>
102             <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
103             <xsl:apply-templates select="utwor" mode="part" />
104
105             <TeXML escape="0">
106                 <xsl:if test="@data-cover-by">
107                 \def\coverby{Okładka na podstawie:
108                     <xsl:choose>
109                     <xsl:when test="@data-cover-source">
110                         \href{\datacoversource}{\datacoverby}
111                     </xsl:when>
112                     <xsl:otherwise>
113                         \datacoverby{}
114                     </xsl:otherwise>
115                     </xsl:choose>
116                 }
117                 </xsl:if>
118                 \def\editors{<TeXML escape="1"><xsl:call-template name="editors" /></TeXML>}
119                 <xsl:if test="@funders">
120                     \def\funders{Publikację wsparli i wsparły:
121                         <TeXML escape="1"><xsl:value-of select="@funders" /></TeXML>.}
122                 </xsl:if>
123
124                 <xsl:if test="@sponsor-note|data-sponsor">
125                     \def\sponsors{
126                         \scriptsize
127                         <xsl:choose>
128                             <xsl:when test="@sponsor-note">
129                                 <TeXML escape="1"><xsl:value-of select="@sponsor-note" /></TeXML>
130                             </xsl:when>
131                             <xsl:otherwise>
132                                 Sfinansowano ze~środków:
133                             </xsl:otherwise>
134                         </xsl:choose>
135
136                         \vspace{1em}
137
138                         <xsl:apply-templates select="data-sponsor" mode="sponsor" />
139                     }
140                 </xsl:if>
141             </TeXML>
142
143             <cmd name="editorialsection" />
144
145         </env>
146     </TeXML>
147 </xsl:template>
148
149 <xsl:template match="utwor" mode="part">
150     <cmd name="tytul"><parm>
151       <xsl:choose>
152         <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
153             <!-- title in master -->
154             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="part_title" />
155             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
156         </xsl:when>
157         <xsl:otherwise>
158             <!-- look for title in dc -->
159             <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
160             <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
161         </xsl:otherwise>
162       </xsl:choose>
163     </parm></cmd>
164
165     <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
166     <xsl:apply-templates select="utwor" mode="part" />
167 </xsl:template>
168
169 <!-- =================== -->
170 <!-- = MAIN TITLE PAGE = -->
171 <!-- = (from DC)       = -->
172 <!-- =================== -->
173
174 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
175     <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
176 </xsl:template>
177
178 <xsl:template match="rdf:RDF" mode="titlepage">
179     <TeXML escape="0">
180         \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
181         \author{\authors}
182         \title{<TeXML escape="1"><xsl:apply-templates select=".//dc:title" mode="inline" /></TeXML>}
183         \def\translatorsline{<TeXML escape="1"><xsl:call-template name="translators" /></TeXML>}
184
185         \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
186
187         \def\rightsinfo{Ten utwór nie jest objęty majątkowym prawem autorskim i~znajduje się w~domenie
188             publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
189             i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
190             (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
191             te dodatkowe materiały udostępnione są na licencji
192             \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
193             Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
194         <xsl:if test=".//dc:rights.license">
195             \def\rightsinfo{Ten utwór jest udostępniony na licencji
196             \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
197         </xsl:if>
198
199         \def\sourceinfo{
200             <xsl:if test=".//dc:source">
201                 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
202                 \vspace{.6em}
203             </xsl:if>}
204         \def\publisherinfo{
205             <xsl:if test=".//dc:publisher">
206                 Wydawca:
207                 <TeXML escape="1">
208                     <xsl:for-each select=".//dc:publisher/text()">
209                         <xsl:value-of select="."/>
210                         <xsl:if test="not(position() = last())">, </xsl:if>
211                     </xsl:for-each>
212                 </TeXML>
213                 \vspace{.6em}
214             </xsl:if>}
215         \def\description{<TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
216         <xsl:if test=".//meta[@id='pdf-id']">
217             <xsl:variable name="isbn" select=".//meta[@id='pdf-id']"/>
218             \def\isbn{ISBN <xsl:value-of select="substring-after($isbn, 'ISBN-')"/>}
219         </xsl:if>
220     </TeXML>
221 </xsl:template>
222
223
224 <!-- ============== -->
225 <!-- = BOOK TITLE = -->
226 <!-- = (from DC)  = -->
227 <!-- ============== -->
228
229 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
230     <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
231 </xsl:template>
232
233 <xsl:template match="rdf:RDF" mode="dctitle">
234     <cmd name="autorpodutworu">
235         <parm><xsl:call-template name="authors" /></parm>
236     </cmd>
237     <cmd name="nazwapodutworu"><parm>
238         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
239     </parm></cmd>
240 </xsl:template>
241
242 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
243     <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
244 </xsl:template>
245
246 <xsl:template match="rdf:RDF" mode="firstdctitle">
247     <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
248     <cmd name="nazwautworu"><parm>
249         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
250     </parm></cmd>
251     <cmd name="translatorsline" />
252 </xsl:template>
253
254
255 <!-- ============================================================================== -->
256 <!-- = MASTER TAG                                                                 = -->
257 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
258 <!-- ============================================================================== -->
259 <!-- ==================================================================================== -->
260 <!-- = BLOCK TAGS                                                                       = -->
261 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
262 <!-- ==================================================================================== -->
263
264 <xsl:template
265     match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
266     <cmd>
267         <xsl:attribute name="name">
268             <xsl:value-of select="wl:texcommand(name())" />
269         </xsl:attribute>
270         <parm><xsl:apply-templates/></parm>
271     </cmd>
272 </xsl:template>
273
274 <xsl:template match="lista_osob">
275     <cmd name="listaosob">
276         <parm><xsl:apply-templates select="naglowek_listy" /></parm>
277         <parm><xsl:apply-templates select="lista_osoba" /></parm>
278     </cmd>
279 </xsl:template>
280
281 <xsl:template match="kwestia">
282     <cmd name="kwestia">
283         <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
284     </cmd>
285 </xsl:template>
286
287 <xsl:template match="ilustr">
288     <cmd name="ilustr">
289         <parm><xsl:value-of select="@src" /></parm>
290         <parm><xsl:value-of select="@alt" /></parm>
291     </cmd>
292 </xsl:template>
293
294 <!-- ========================================== -->
295 <!-- = PARAGRAPH TAGS                         = -->
296 <!-- = (can contain inline and special tags)  = -->
297 <!-- ========================================== -->
298
299 <!-- only in root -->
300 <xsl:template
301     match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
302     mode="title">
303     <cmd>
304         <xsl:attribute name="name">
305             <xsl:value-of select="wl:texcommand(name())" />
306         </xsl:attribute>
307         <parm><xsl:apply-templates mode="inline"/></parm>
308     </cmd>
309 </xsl:template>
310
311 <xsl:template match="nazwa_utworu" mode="part_title">
312     <xsl:if test="../../rdf:RDF//use_subauthor">
313         <cmd name="autorpodutworu"><parm><xsl:call-template name="authors2"/></parm></cmd>
314     </xsl:if>
315     <cmd name="nazwapodutworu">
316         <parm><xsl:apply-templates mode="inline"/></parm>
317         <parm>
318             <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
319                 <xsl:choose>
320                     <xsl:when test="name() = 'nbsp'">
321                         <xsl:text> </xsl:text>
322                     </xsl:when>
323                     <xsl:when test="name() = 'dywiz'">
324                         <xsl:text>-</xsl:text>
325                     </xsl:when>
326                     <xsl:when test="name() = 'alien' or name() = 'slowo_obce'">
327                         <xsl:apply-templates mode="inline" />
328                     </xsl:when>
329                     <xsl:otherwise>
330                         <xsl:value-of select="."/>
331                     </xsl:otherwise>
332                 </xsl:choose>
333             </xsl:for-each>
334         </parm>
335     </cmd>
336 </xsl:template>
337
338
339 <xsl:template
340     match="naglowek_osoba|naglowek_podrozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_diafrlog|akap_cd|motto_podpis|naglowek_listy|srodtytul">
341     <cmd>
342         <xsl:attribute name="name">
343             <xsl:value-of select="wl:texcommand(name())" />
344         </xsl:attribute>
345         <parm><xsl:apply-templates mode="inline"/></parm>
346     </cmd>
347 </xsl:template>
348
349 <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
350     <cmd>
351         <xsl:attribute name="name">
352             <xsl:value-of select="wl:texcommand(name())" />
353         </xsl:attribute>
354         <parm><xsl:apply-templates mode="inline"/></parm>
355         <parm>
356             <!-- osobny szablon? -->
357             <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
358                 <xsl:choose>
359                     <xsl:when test="name() = 'nbsp'">
360                         <xsl:text> </xsl:text>
361                     </xsl:when>
362                     <xsl:when test="name() = 'dywiz'">
363                         <xsl:text>-</xsl:text>
364                     </xsl:when>
365                     <xsl:when test="name() = 'alien'">
366                         <xsl:apply-templates mode="inline" />
367                     </xsl:when>
368                     <xsl:when test="name() = 'slowo_obce'">
369                         <cmd name="slowoobce">
370                             <parm><xsl:value-of select="text()"/></parm>
371                         </cmd>
372                     </xsl:when>
373                     <xsl:otherwise>
374                         <xsl:value-of select="."/>
375                     </xsl:otherwise>
376                 </xsl:choose>
377             </xsl:for-each>
378         </parm>
379     </cmd>
380 </xsl:template>
381
382 <xsl:template match="strofa" mode="inline">
383     <env name="minipage">
384         <opt>t</opt>
385         <parm><cmd name="linewidth" /></parm>
386         <parm><xsl:apply-templates select="." /></parm>
387     </env>
388 </xsl:template>
389
390 <xsl:template match="strofa">
391   <cmd name="strofa"><parm>
392     <xsl:choose>
393         <xsl:when test="count(br) > 0">
394             <xsl:call-template name="verse">
395                 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
396                 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd' or name() = 'wers_do_prawej'][1]" />
397             </xsl:call-template>
398             <xsl:for-each select="br">
399                 <TeXML escape="0">\\{}</TeXML>
400                 <!-- Each BR tag "consumes" text after it -->
401                 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
402                 <xsl:call-template name="verse">
403                     <xsl:with-param name="verse-content"
404                         select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
405                     <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' or name() = 'wers_do_prawej')][1]" />
406                 </xsl:call-template>
407             </xsl:for-each>
408         </xsl:when>
409         <xsl:otherwise>
410             <xsl:call-template name="verse">
411                 <xsl:with-param name="verse-content" select="text() | node()" />
412                 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
413             </xsl:call-template>
414         </xsl:otherwise>
415     </xsl:choose>
416   </parm></cmd>
417 </xsl:template>
418
419
420 <xsl:template name="verse">
421     <xsl:param name="verse-content" />
422     <xsl:param name="verse-type" />
423
424     <cmd>
425         <xsl:attribute name="name">
426             <xsl:choose>
427                 <xsl:when test="$verse-type != ''">
428                     <xsl:value-of select='wl:texcommand(name($verse-type))' />
429                 </xsl:when>
430                 <xsl:otherwise>wers</xsl:otherwise>
431             </xsl:choose>
432         </xsl:attribute>
433         <xsl:if test="string($verse-content/@typ)">
434             <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
435         </xsl:if>
436         <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
437     </cmd>
438 </xsl:template>
439
440 <!-- ================================================ -->
441 <!-- = INLINE TAGS                                  = -->
442 <!-- = (contain other inline tags and special tags) = -->
443 <!-- ================================================ -->
444
445 <xsl:template mode="inline"
446     match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
447     <cmd>
448         <xsl:attribute name="name">
449             <xsl:value-of select="wl:texcommand(name())" />
450         </xsl:attribute>
451         <parm><xsl:apply-templates mode="inline"/></parm>
452     </cmd>
453 </xsl:template>
454
455
456
457 <xsl:template match="tytul_dziela" mode="inline">
458     <cmd name="tytuldziela"><parm>
459         <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
460     </parm></cmd>
461 </xsl:template>
462
463
464
465 <!-- ============================================== -->
466 <!-- = STANDALONE TAGS                            = -->
467 <!-- = (cannot contain any other tags)            = -->
468 <!-- ============================================== -->
469 <xsl:template
470     match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
471     <cmd>
472         <xsl:attribute name="name">
473             <xsl:value-of select="wl:texcommand(name())" />
474         </xsl:attribute>
475     </cmd>
476 </xsl:template>
477
478
479 <!-- ================ -->
480 <!-- = SPECIAL TAGS = -->
481 <!-- ================ -->
482 <!-- Themes -->
483
484
485 <xsl:template match="begin|end|motyw">
486     <xsl:apply-templates select='.' mode="inline" />
487 </xsl:template>
488
489 <xsl:template match="begin" mode="inline" />
490 <xsl:template match="end" mode="inline" />
491
492 <xsl:template match="motyw" mode="inline">
493     <cmd name="motyw">
494         <xsl:if test="@moved">
495             <opt name="moved"><xsl:value-of select="@moved" /></opt>
496         </xsl:if>
497         <parm><xsl:apply-templates mode="inline" /></parm>
498     </cmd>
499 </xsl:template>
500
501 <xsl:template name="authors">
502     <xsl:for-each select=".//dc:creator_parsed">
503         <xsl:if test="position() != 1">, </xsl:if>
504         <xsl:apply-templates mode="inline" />
505     </xsl:for-each>
506 </xsl:template>
507
508 <xsl:template name="authors2">
509     <xsl:for-each select="../..//dc:creator_parsed">
510         <xsl:if test="position() != 1">, </xsl:if>
511         <xsl:apply-templates mode="inline" />
512     </xsl:for-each>
513 </xsl:template>
514
515 <xsl:template name="editors">
516     <xsl:if test="@editors">
517         <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
518         <xsl:value-of select="@editors" />
519         <xsl:text>.</xsl:text>
520     </xsl:if>
521 </xsl:template>
522
523 <xsl:template name="translators">
524     <xsl:if test=".//dc:contributor.translator_parsed">
525         <cmd name='translator'><parm>
526             <xsl:for-each select=".//dc:contributor.translator_parsed">
527                 <xsl:if test="position() != 1">, </xsl:if>
528                 <xsl:apply-templates mode="inline" />
529             </xsl:for-each>
530         </parm></cmd>
531     </xsl:if>
532 </xsl:template>
533
534 <xsl:template match="data-sponsor" mode="sponsor">
535     <cmd name="par"><parm>
536     <xsl:choose>
537         <xsl:when test="@src">
538             \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
539         </xsl:when>
540         <xsl:otherwise>
541             <xsl:value-of select="@name" />
542         </xsl:otherwise>
543     </xsl:choose>
544     </parm></cmd>
545 </xsl:template>
546
547 <xsl:template match="mat" mode="inline">
548     <TeXML escape="0">
549         <xsl:text>$</xsl:text>
550         <xsl:value-of select="wl:mathml_latex(.)" />
551         <xsl:text>$</xsl:text>
552     </TeXML>
553 </xsl:template>
554
555 <xsl:template match="mat">
556     <TeXML escape="0">
557         <xsl:text>$$</xsl:text>
558         <xsl:value-of select="wl:mathml_latex(.)" />
559         <xsl:text>$$</xsl:text>
560     </TeXML>
561 </xsl:template>
562
563 <xsl:template match="tabela|tabelka">
564     <cmd name="par" />
565     <cmd name="vspace"><parm>1em</parm></cmd>
566     <group><cmd name="raggedright" />
567     <xsl:element name="env">
568         <xsl:attribute name="name">
569             <xsl:choose>
570                 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
571                 <xsl:otherwise>tabu</xsl:otherwise>
572             </xsl:choose>
573         </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
574       <!--parm><cmd name="textwidth"/></parm-->
575       <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
576         <xsl:choose>
577         <xsl:when test="@ramka='1' or @ramki='1'">
578           <cmd name="hline" />
579           <xsl:apply-templates mode="wiersze-ramki"/>
580         </xsl:when>
581         <xsl:otherwise>
582           <xsl:apply-templates/>
583         </xsl:otherwise>
584         </xsl:choose>
585     </xsl:element>
586     </group>
587     <cmd name="vspace"><parm>1em</parm></cmd>
588 </xsl:template>
589 <xsl:template match="wiersz" mode="wiersze-ramki">
590     <xsl:apply-templates />
591     <spec cat="esc"/><spec cat="esc"/>
592     <cmd name="hline" gr="0" />
593 </xsl:template>
594 <xsl:template match="wiersz">
595     <xsl:apply-templates />
596     <spec cat="esc"/><spec cat="esc"/>
597 </xsl:template>
598 <xsl:template match="kol">
599     <xsl:apply-templates mode="inline"/>
600     <xsl:if test="position() &lt; last()">
601     <spec cat="align"/>
602     </xsl:if>
603 </xsl:template>
604
605
606 <!-- ============== -->
607 <!-- = ADDED TAGS = -->
608 <!-- ============== -->
609
610
611 <xsl:template match="dywiz" mode="inline">
612     <cmd name="dywiz" />
613 </xsl:template>
614
615 <xsl:template match="nbsp" mode="inline">
616     <spec cat="tilde" />
617 </xsl:template>
618
619 <xsl:template match="alien" mode="inline">
620     <group>
621         <cmd name="alien" />
622         <xsl:apply-templates mode="inline" />
623     </group>
624 </xsl:template>
625
626 <!-- ================ -->
627 <!-- = IGNORED TAGS = -->
628 <!-- ================ -->
629 <xsl:template match="extra|uwaga" />
630 <xsl:template match="extra|uwaga" mode="inline" />
631
632 <xsl:template match="nota_red" />
633 <xsl:template match="abstrakt" />
634
635 <!-- ======== -->
636 <!-- = TEXT = -->
637 <!-- ======== -->
638 <xsl:template match="text()" />
639 <xsl:template match="text()" mode="inline">
640     <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
641       <xsl:text> </xsl:text>
642     </xsl:if>
643
644     <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
645
646     <xsl:if test="following-sibling::node() and wl:ends_white(.)">
647       <xsl:text> </xsl:text>
648     </xsl:if>
649 </xsl:template>
650
651
652 </xsl:stylesheet>