Legimi cover classes.
[librarian.git] / src / 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             <TeXML escape="0">
144                     \ifendnotes
145 \newpage
146 \begingroup
147 \parindent 0pt
148 \parskip 2ex
149 \def\enotesize{\normalsize}
150 \printendnotes
151                     \endgroup
152                     \fi
153             </TeXML>
154
155             <cmd name="editorialsection" />
156
157         </env>
158     </TeXML>
159 </xsl:template>
160
161 <xsl:template match="utwor" mode="part">
162     <cmd name="tytul"><parm>
163       <xsl:choose>
164         <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
165             <!-- title in master -->
166             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="part_title" />
167             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
168         </xsl:when>
169         <xsl:otherwise>
170             <!-- look for title in dc -->
171             <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
172             <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
173         </xsl:otherwise>
174       </xsl:choose>
175     </parm></cmd>
176
177     <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
178     <xsl:apply-templates select="utwor" mode="part" />
179 </xsl:template>
180
181 <!-- =================== -->
182 <!-- = MAIN TITLE PAGE = -->
183 <!-- = (from DC)       = -->
184 <!-- =================== -->
185
186 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
187     <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
188 </xsl:template>
189
190 <xsl:template match="rdf:RDF" mode="titlepage">
191     <TeXML escape="0">
192         \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
193         \author{\authors}
194         \title{<TeXML escape="1"><xsl:apply-templates select=".//dc:title" mode="inline" /></TeXML>}
195         \def\translatorsline{<TeXML escape="1"><xsl:call-template name="translators" /></TeXML>}
196
197         \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
198
199         \def\rightsinfo{Ten utwór nie jest objęty majątkowym prawem autorskim i~znajduje się w~domenie
200             publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
201             i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
202             (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
203             te dodatkowe materiały udostępnione są na licencji
204             \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
205             Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
206         <xsl:if test=".//dc:rights.license">
207             \def\rightsinfo{Ten utwór jest udostępniony na licencji
208             \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
209         </xsl:if>
210
211         \def\sourceinfo{
212             <xsl:if test=".//dc:source">
213                 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
214                 \vspace{.6em}
215             </xsl:if>}
216         \def\publisherinfo{
217             <xsl:if test=".//dc:publisher">
218                 Wydawca:
219                 <TeXML escape="1">
220                     <xsl:for-each select=".//dc:publisher/text()">
221                         <xsl:value-of select="."/>
222                         <xsl:if test="not(position() = last())">, </xsl:if>
223                     </xsl:for-each>
224                 </TeXML>
225                 \vspace{.6em}
226             </xsl:if>}
227         \def\description{<TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
228         <xsl:if test=".//meta[@id='pdf-id']">
229             <xsl:variable name="isbn" select=".//meta[@id='pdf-id']"/>
230             \def\isbn{ISBN <xsl:value-of select="substring-after($isbn, 'ISBN-')"/>}
231         </xsl:if>
232     </TeXML>
233 </xsl:template>
234
235
236 <!-- ============== -->
237 <!-- = BOOK TITLE = -->
238 <!-- = (from DC)  = -->
239 <!-- ============== -->
240
241 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
242     <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
243 </xsl:template>
244
245 <xsl:template match="rdf:RDF" mode="dctitle">
246     <xsl:if test="../../rdf:RDF//use_subauthor">
247         <cmd name="autorpodutworu">
248             <parm><xsl:call-template name="authors" /></parm>
249         </cmd>
250     </xsl:if>
251     <cmd name="nazwanadpodutworu"><parm>
252         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
253     </parm>
254     <parm>
255         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
256     </parm></cmd>
257 </xsl:template>
258
259 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
260     <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
261 </xsl:template>
262
263 <xsl:template match="rdf:RDF" mode="firstdctitle">
264     <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
265     <cmd name="nazwautworu"><parm>
266         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
267     </parm></cmd>
268     <cmd name="translatorsline" />
269 </xsl:template>
270
271
272 <!-- ============================================================================== -->
273 <!-- = MASTER TAG                                                                 = -->
274 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
275 <!-- ============================================================================== -->
276 <!-- ==================================================================================== -->
277 <!-- = BLOCK TAGS                                                                       = -->
278 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
279 <!-- ==================================================================================== -->
280
281 <xsl:template
282     match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
283     <cmd>
284         <xsl:attribute name="name">
285             <xsl:value-of select="wl:texcommand(name())" />
286         </xsl:attribute>
287         <parm><xsl:apply-templates/></parm>
288     </cmd>
289 </xsl:template>
290
291 <xsl:template match="lista_osob">
292     <cmd name="listaosob">
293         <parm><xsl:apply-templates select="naglowek_listy" /></parm>
294         <parm><xsl:apply-templates select="lista_osoba" /></parm>
295     </cmd>
296 </xsl:template>
297
298 <xsl:template match="kwestia">
299     <cmd name="kwestia">
300         <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
301     </cmd>
302 </xsl:template>
303
304 <xsl:template match="ilustr">
305   <xsl:choose>
306     <xsl:when test="@oblew = 'true'">
307       <cmd name="par"/>
308       <env name="wrapfigure">
309         <parm>R</parm>
310         <parm>5cm</parm>
311         <cmd name="includegraphics">
312           <opt>width=<cmd name="linewidth"/></opt>
313           <parm><xsl:value-of select="@src"/></parm>
314         </cmd>
315       </env>
316     </xsl:when>
317     <xsl:otherwise>
318       <cmd name="ilustr">
319         <parm><xsl:value-of select="@src" /></parm>
320         <parm><xsl:value-of select="@alt" /></parm>
321       </cmd>
322     </xsl:otherwise>
323   </xsl:choose>
324 </xsl:template>
325
326 <!-- ========================================== -->
327 <!-- = PARAGRAPH TAGS                         = -->
328 <!-- = (can contain inline and special tags)  = -->
329 <!-- ========================================== -->
330
331 <!-- only in root -->
332 <xsl:template
333     match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
334     mode="title">
335     <cmd>
336         <xsl:attribute name="name">
337             <xsl:value-of select="wl:texcommand(name())" />
338         </xsl:attribute>
339         <parm><xsl:apply-templates mode="inline"/></parm>
340     </cmd>
341 </xsl:template>
342
343 <xsl:template match="nazwa_utworu" mode="part_title">
344     <xsl:if test="../../rdf:RDF//use_subauthor">
345         <cmd name="autorpodutworu"><parm><xsl:call-template name="authors2"/></parm></cmd>
346     </xsl:if>
347     <cmd name="nazwapodutworu">
348         <parm><xsl:apply-templates mode="inline"/></parm>
349         <parm>
350             <xsl:call-template name="strip-for-toc" />
351         </parm>
352     </cmd>
353 </xsl:template>
354
355
356 <xsl:template
357     match="naglowek_osoba|naglowek_podrozdzial|podtytul_podrozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy|srodtytul|podtytul_czesc|podtytul_rozdzial|podtytul_akt|podtytul_scena">
358   <xsl:choose>
359     <xsl:when test="@inline">
360       <xsl:apply-templates mode="inline"/>
361     </xsl:when>
362     <xsl:otherwise>
363       <cmd>
364         <xsl:attribute name="name">
365             <xsl:value-of select="wl:texcommand(name())" />
366         </xsl:attribute>
367         <parm><xsl:apply-templates mode="inline"/></parm>
368       </cmd>
369     </xsl:otherwise>
370   </xsl:choose>
371 </xsl:template>
372
373 <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
374     <cmd>
375         <xsl:attribute name="name">
376             <xsl:value-of select="wl:texcommand(name())" />
377         </xsl:attribute>
378         <parm><xsl:apply-templates mode="inline"/></parm>
379         <parm>
380             <xsl:call-template name="strip-for-toc" />
381         </parm>
382     </cmd>
383 </xsl:template>
384
385 <xsl:template match="strofa" mode="inline">
386     <env name="minipage">
387         <opt>t</opt>
388         <parm><cmd name="linewidth" /></parm>
389         <parm><xsl:apply-templates select="." /></parm>
390     </env>
391 </xsl:template>
392
393 <xsl:template match="strofa">
394   <cmd name="strofa"><parm>
395     <xsl:choose>
396         <xsl:when test="count(br) > 0">
397             <xsl:call-template name="verse">
398                 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
399                 <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]" />
400             </xsl:call-template>
401             <xsl:for-each select="br">
402                 <TeXML escape="0">\\{}</TeXML>
403                 <!-- Each BR tag "consumes" text after it -->
404                 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
405                 <xsl:call-template name="verse">
406                     <xsl:with-param name="verse-content"
407                         select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
408                     <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]" />
409                 </xsl:call-template>
410             </xsl:for-each>
411         </xsl:when>
412         <xsl:otherwise>
413             <xsl:call-template name="verse">
414                 <xsl:with-param name="verse-content" select="text() | node()" />
415                 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
416             </xsl:call-template>
417         </xsl:otherwise>
418     </xsl:choose>
419   </parm></cmd>
420 </xsl:template>
421
422
423 <xsl:template name="verse">
424     <xsl:param name="verse-content" />
425     <xsl:param name="verse-type" />
426
427     <cmd>
428         <xsl:attribute name="name">
429             <xsl:choose>
430                 <xsl:when test="$verse-type != ''">
431                     <xsl:value-of select='wl:texcommand(name($verse-type))' />
432                 </xsl:when>
433                 <xsl:otherwise>wers</xsl:otherwise>
434             </xsl:choose>
435         </xsl:attribute>
436         <xsl:if test="string($verse-content/@typ)">
437             <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
438         </xsl:if>
439         <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
440     </cmd>
441 </xsl:template>
442
443 <!-- ================================================ -->
444 <!-- = INLINE TAGS                                  = -->
445 <!-- = (contain other inline tags and special tags) = -->
446 <!-- ================================================ -->
447
448
449 <xsl:template mode="inline"
450     match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
451     <cmd>
452         <xsl:attribute name="name">
453                 <xsl:value-of select="wl:texcommand(name())" />
454         </xsl:attribute>
455         <parm>
456           <xsl:choose>
457             <xsl:when test="@blocks">
458               <xsl:apply-templates/>
459             </xsl:when>
460             <xsl:otherwise>
461               <xsl:apply-templates mode="inline"/>
462             </xsl:otherwise>
463           </xsl:choose>
464         </parm>
465     </cmd>
466 </xsl:template>
467
468
469
470 <xsl:template match="tytul_dziela" mode="inline">
471     <cmd name="tytuldziela"><parm>
472         <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
473     </parm></cmd>
474 </xsl:template>
475
476
477
478 <!-- ============================================== -->
479 <!-- = STANDALONE TAGS                            = -->
480 <!-- = (cannot contain any other tags)            = -->
481 <!-- ============================================== -->
482 <xsl:template
483     match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
484     <cmd>
485         <xsl:attribute name="name">
486             <xsl:value-of select="wl:texcommand(name())" />
487         </xsl:attribute>
488     </cmd>
489 </xsl:template>
490
491
492 <!-- ================ -->
493 <!-- = SPECIAL TAGS = -->
494 <!-- ================ -->
495 <!-- Themes -->
496
497
498 <xsl:template match="begin|end|motyw">
499     <xsl:apply-templates select='.' mode="inline" />
500 </xsl:template>
501
502 <xsl:template match="begin" mode="inline" />
503 <xsl:template match="end" mode="inline" />
504
505 <xsl:template match="motyw" mode="inline">
506     <cmd name="motyw">
507         <xsl:if test="@moved">
508             <opt name="moved"><xsl:value-of select="@moved" /></opt>
509         </xsl:if>
510         <parm><xsl:apply-templates mode="inline" /></parm>
511     </cmd>
512 </xsl:template>
513
514 <xsl:template name="authors">
515     <xsl:for-each select=".//dc:creator_parsed">
516         <xsl:if test="position() != 1">, </xsl:if>
517         <xsl:apply-templates mode="inline" />
518     </xsl:for-each>
519 </xsl:template>
520
521 <xsl:template name="authors2">
522     <xsl:for-each select="../..//dc:creator_parsed">
523         <xsl:if test="position() != 1">, </xsl:if>
524         <xsl:apply-templates mode="inline" />
525     </xsl:for-each>
526 </xsl:template>
527
528 <xsl:template name="editors">
529     <xsl:if test="@editors">
530         <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
531         <xsl:value-of select="@editors" />
532         <xsl:text>.</xsl:text>
533     </xsl:if>
534 </xsl:template>
535
536 <xsl:template name="translators">
537     <xsl:if test=".//dc:contributor.translator_parsed">
538         <cmd name='translator'><parm>
539             <xsl:for-each select=".//dc:contributor.translator_parsed">
540                 <xsl:if test="position() != 1">, </xsl:if>
541                 <xsl:apply-templates mode="inline" />
542             </xsl:for-each>
543         </parm></cmd>
544     </xsl:if>
545 </xsl:template>
546
547 <xsl:template name="strip-for-toc">
548     <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
549         <xsl:choose>
550             <xsl:when test="name() = 'nbsp'">
551                 <xsl:text> </xsl:text>
552             </xsl:when>
553             <xsl:when test="name() = 'dywiz'">
554                 <xsl:text>-</xsl:text>
555             </xsl:when>
556             <xsl:when test="name() = 'alien'">
557                 <xsl:apply-templates mode="inline" />
558             </xsl:when>
559             <xsl:when test="name() = 'slowo_obce'">
560                 <xsl:call-template name="strip-for-toc" />
561             </xsl:when>
562             <xsl:otherwise>
563                 <xsl:value-of select="."/>
564             </xsl:otherwise>
565         </xsl:choose>
566     </xsl:for-each>
567 </xsl:template>
568
569 <xsl:template match="data-sponsor" mode="sponsor">
570     <cmd name="par"><parm>
571     <xsl:choose>
572         <xsl:when test="@src">
573             \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
574         </xsl:when>
575         <xsl:otherwise>
576             <xsl:value-of select="@name" />
577         </xsl:otherwise>
578     </xsl:choose>
579     </parm></cmd>
580 </xsl:template>
581
582 <xsl:template match="mat" mode="inline">
583     <TeXML escape="0">
584         <xsl:text>$</xsl:text>
585         <xsl:value-of select="wl:mathml_latex(.)" />
586         <xsl:text>$</xsl:text>
587     </TeXML>
588 </xsl:template>
589
590 <xsl:template match="mat">
591     <TeXML escape="0">
592         <xsl:text>$$</xsl:text>
593         <xsl:value-of select="wl:mathml_latex(.)" />
594         <xsl:text>$$</xsl:text>
595     </TeXML>
596 </xsl:template>
597
598 <xsl:template match="tabela|tabelka">
599     <cmd name="par" />
600     <cmd name="vspace"><parm>1em</parm></cmd>
601     <group><cmd name="raggedright" />
602     <xsl:element name="env">
603         <xsl:attribute name="name">
604             <xsl:choose>
605                 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
606                 <xsl:otherwise>tabu</xsl:otherwise>
607             </xsl:choose>
608         </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
609       <!--parm><cmd name="textwidth"/></parm-->
610       <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
611         <xsl:choose>
612         <xsl:when test="@ramka='1' or @ramki='1'">
613           <cmd name="hline" />
614           <xsl:apply-templates mode="wiersze-ramki"/>
615         </xsl:when>
616         <xsl:otherwise>
617           <xsl:apply-templates/>
618         </xsl:otherwise>
619         </xsl:choose>
620     </xsl:element>
621     </group>
622     <cmd name="vspace"><parm>1em</parm></cmd>
623 </xsl:template>
624 <xsl:template match="wiersz" mode="wiersze-ramki">
625     <xsl:apply-templates />
626     <spec cat="esc"/><spec cat="esc"/>
627     <cmd name="hline" gr="0" />
628 </xsl:template>
629 <xsl:template match="wiersz">
630     <xsl:apply-templates />
631     <spec cat="esc"/><spec cat="esc"/>
632 </xsl:template>
633 <xsl:template match="kol">
634     <xsl:apply-templates mode="inline"/>
635     <xsl:if test="position() &lt; last()">
636     <spec cat="align"/>
637     </xsl:if>
638 </xsl:template>
639
640
641 <!-- ============== -->
642 <!-- = ADDED TAGS = -->
643 <!-- ============== -->
644
645
646 <xsl:template match="dywiz" mode="inline">
647     <cmd name="dywiz" />
648 </xsl:template>
649
650 <xsl:template match="nbsp" mode="inline">
651     <spec cat="tilde" />
652 </xsl:template>
653
654 <xsl:template match="alien" mode="inline">
655     <group>
656         <cmd name="alien" />
657         <xsl:apply-templates mode="inline" />
658     </group>
659 </xsl:template>
660
661 <!-- ================ -->
662 <!-- = IGNORED TAGS = -->
663 <!-- ================ -->
664 <xsl:template match="extra|uwaga" />
665 <xsl:template match="extra|uwaga" mode="inline" />
666
667 <xsl:template match="nota_red" />
668 <xsl:template match="abstrakt" />
669
670 <!-- ======== -->
671 <!-- = TEXT = -->
672 <!-- ======== -->
673 <xsl:template match="text()" />
674 <xsl:template match="text()" mode="inline">
675     <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
676       <xsl:text> </xsl:text>
677     </xsl:if>
678
679     <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
680
681     <xsl:if test="following-sibling::node() and wl:ends_white(.)">
682       <xsl:text> </xsl:text>
683     </xsl:if>
684 </xsl:template>
685
686
687 </xsl:stylesheet>