Support for <wers>.
[redakcja.git] / src / redakcja / static / xsl / wl2html_client.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"    
3     xmlns="http://www.w3.org/1999/xhtml"    
4     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
6     <!--
7         Dokument ten opisuje jednoznaczne przekształcenie WLML 0.1 -> XHTML.
8     -->        
9     <xsl:output method="html" omit-xml-declaration="yes" encoding="utf-8" indent="no" />
10
11     <!--
12         Base tag for rendering a fragment of text
13     -->
14     <xsl:template match="chunk">        
15         <xsl:apply-templates select="child::node()">            
16             <xsl:with-param name="mixed" select="true()" />
17         </xsl:apply-templates>        
18     </xsl:template>
19     
20     <!--
21         Base tag for rendering the whole text 
22     -->
23
24     <xsl:template match="utwor">
25         <div>
26             <xsl:call-template name="standard-attributes" />
27             <xsl:apply-templates select="child::node()">
28                 <xsl:with-param name="mixed" select="false()" />
29             </xsl:apply-templates>
30         </div>
31     </xsl:template>    
32     
33     <!-- 
34         Przekształcenia poszczególnych elementów zgodnie z:            
35         http://wiki.wolnepodreczniki.pl/Lektury:Sk%C5%82ad/Tagi_sk%C5%82adu
36     -->
37
38     <!-- TAGI MASTERÓW STYLÓW
39     
40         Tagi rozpoczynające i kończące tekst utworu lirycznego o standardowej szerokości łamu:
41     -->
42
43     <xsl:template match="opowiadanie|powiesc">
44         <xsl:param name="mixed" />
45         <div>
46             <xsl:call-template name="standard-attributes" />
47             <xsl:apply-templates select="child::node()">
48                 <xsl:with-param name="mixed" select="false()" />
49             </xsl:apply-templates>
50         </div>
51     </xsl:template>
52
53     <xsl:template match="liryka_l|liryka_lp">
54         <xsl:param name="mixed" />
55         <div>
56             <xsl:call-template name="standard-attributes" />
57             <xsl:apply-templates select="child::node()">
58                 <xsl:with-param name="mixed" select="false()" />
59             </xsl:apply-templates>
60         </div>
61     </xsl:template>
62
63     <xsl:template match="dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
64         <xsl:param name="mixed" />
65         <div>
66             <xsl:call-template name="standard-attributes" />
67             <xsl:apply-templates select="child::node()">
68                 <xsl:with-param name="mixed" select="false()" />
69             </xsl:apply-templates>
70         </div>
71     </xsl:template>
72
73     <xsl:template match="wywiad">
74         <xsl:param name="mixed" />
75         <div>
76             <xsl:call-template name="standard-attributes" />
77             <xsl:apply-templates select="child::node()">
78                 <xsl:with-param name="mixed" select="false()" />
79             </xsl:apply-templates>
80         </div>
81     </xsl:template>
82
83     <!-- 
84         *****************************
85         ELEMENTY POZA TEKSTEM GŁÓWNYM
86         *****************************
87     -->
88
89     <!--
90         Autor składanego utworu
91
92         Element strony tytułowej - lub odpowiadającej jej przestrzeni,
93         np. na stronie internetowej) :
94
95         <autor_utworu> imiona-itd.-autora-składanego-utworu </autor_utworu>
96     -->
97     <xsl:template match="autor_utworu">
98         <xsl:param name="mixed" />
99         <h2 x-editable="true">
100             <xsl:call-template name="standard-attributes" />
101             <xsl:call-template name="context-menu" />
102             <xsl:apply-templates select="child::node()">
103                 <xsl:with-param name="mixed" select="true()" />
104             </xsl:apply-templates>
105         </h2>
106     </xsl:template>
107
108     <!-- 
109         Nazwa składanego utworu
110
111         Element strony tytułowej - lub odpowiadającej jej przestrzeni,
112         np. na stronie internetowej
113
114         <nazwa_utworu> tytuł-składanego-utworu </nazwa_utworu>
115     -->
116     <xsl:template match="nazwa_utworu">
117         <xsl:param name="mixed" />
118         <h1 x-editable="true">
119             <xsl:call-template name="standard-attributes" />
120             <xsl:call-template name="context-menu" />
121             <xsl:apply-templates select="child::node()">
122                 <xsl:with-param name="mixed" select="true()" />
123             </xsl:apply-templates>
124         </h1>
125     </xsl:template>
126
127     <!--
128         Nazwa utworu nadrzędnego, w którego skład wchodzi dany utwór
129         <dzielo_nadrzedne> tytuł-dzieła-nadrzędnego </dzielo_nadrzedne>
130
131          Przykład:
132
133          <utwor>
134          <liryka_l>
135             <autor_utworu>Bruno Jasieński</autor_utworu>
136             <dzielo_nadrzedne>But w butonierce</dzielo_nadrzedne>
137             <nazwa_utworu>Deszcz</nazwa_utworu>
138             ....
139     -->
140     <xsl:template match="dzielo_nadrzedne">
141         <xsl:param name="mixed" />
142         <h2 x-editable="true">
143             <xsl:call-template name="standard-attributes" />
144             <xsl:call-template name="context-menu" />
145             <xsl:apply-templates select="child::node()">
146                 <xsl:with-param name="mixed" select="true()" />
147             </xsl:apply-templates>
148         </h2>
149     </xsl:template>
150
151     <!--
152         Podtytuł, czyli wszystkie dopiski do tytułu
153
154         Element strony tytułowej - lub odpowiadającej jej przestrzeni.
155         <podtytul> podtytuł-składanego-utworu </podtytul>
156
157         Przykład:
158         <utwor>
159             <powiesc>
160             <autor_utworu>Daniel Defoe</autor_utworu>
161             <nazwa_utworu>Robinson Crusoe</nazwa_utworu>
162             <podtytul>Jego życia losy, doświadczenia i przypadki</podtytul>
163             ...
164     -->
165     <xsl:template match="podtytul">
166         <xsl:param name="mixed" />
167         <h3 x-editable="true">
168             <xsl:call-template name="standard-attributes" />
169             <xsl:call-template name="context-menu" />
170             <xsl:apply-templates select="child::node()">
171                 <xsl:with-param name="mixed" select="true()" />
172             </xsl:apply-templates>
173         </h3>
174     </xsl:template>
175
176     <!--
177        Tagi obejmujące tekst noty poprzedzającej tekst główny (styl wieloakapitowy):
178
179         <nota><akap> tekst-noty </akap></nota> (styl wieloakapitowy)
180     -->
181
182     <xsl:template match="nota">
183         <xsl:param name="mixed" />
184         <div>
185             <xsl:call-template name="standard-attributes" />
186             <xsl:apply-templates select="child::node()">
187                 <xsl:with-param name="mixed" select="false()" />
188             </xsl:apply-templates>
189         </div>
190     </xsl:template>
191
192     <xsl:template match="nota_red">
193         <xsl:param name="mixed" />
194         <div>
195             <xsl:call-template name="standard-attributes" />
196             <xsl:apply-templates select="child::node()">
197                 <xsl:with-param name="mixed" select="false()" />
198             </xsl:apply-templates>
199         </div>
200     </xsl:template>
201
202     <!--
203         Tagi obejmujące tekst dedykacji (styl wieloakapitowy bądź wielostrofowy):
204         <dedykacja> tekst-dedykacji </dedykacja>
205     -->
206     <xsl:template match="dedykacja">
207         <xsl:param name="mixed" />
208         <div>
209             <xsl:call-template name="standard-attributes" />
210             <xsl:apply-templates select="child::node()">
211                 <xsl:with-param name="mixed" select="false()" />
212             </xsl:apply-templates>
213         </div>
214     </xsl:template>
215
216     <!--
217         Tagi obejmujące tekst w ramce (styl wieloakapitowy bądź wielostrofowy):
218         <ramka> tekst-w-ramce </ramka>
219     -->
220     <xsl:template match="ramka">
221         <xsl:param name="mixed" />
222         <div>
223             <xsl:call-template name="standard-attributes" />
224             <xsl:apply-templates select="child::node()">
225                 <xsl:with-param name="mixed" select="false()" />
226             </xsl:apply-templates>
227         </div>
228     </xsl:template>
229
230     <!--
231         Tagi obejmujące tekst motta (styl wieloakapitowy bądź wielostrofowy):
232         <motto> tekst-motta </motto>
233     -->
234     <xsl:template match="motto">
235         <xsl:param name="mixed" />
236         <div class="motto_container" data-pass-thru="true">
237         <div x-editable="true">
238             <xsl:call-template name="standard-attributes" />
239             <xsl:apply-templates select="child::node()">
240                 <xsl:with-param name="mixed" select="true()" />
241             </xsl:apply-templates>            
242         </div>
243         <xsl:apply-templates select="following-sibling::*[1][self::motto_podpis]" mode="motto">
244             <xsl:with-param name="mixed" select="true()" />
245         </xsl:apply-templates>
246         </div>
247     </xsl:template>
248
249     <!--  
250         Catch stand-alone "motto_podpis" and make then render properly.
251         If not, editing will fail :(.
252         
253         TODO: Make "motto" & "motto_podpis" one block in edit mode (like strofa) 
254     -->
255     <xsl:template match="motto_podpis[not(preceding-sibling::*[1][self::motto])]">
256         <xsl:apply-templates select="." mode="motto">
257             <xsl:with-param name="mixed" select="true()" />
258         </xsl:apply-templates>
259     </xsl:template>        
260         
261     <xsl:template match="motto_podpis" mode="motto">
262         <xsl:param name="mixed" />
263         <p x-editable="true">
264             <xsl:call-template name="standard-attributes" />
265             <xsl:call-template name="context-menu" />
266             <xsl:apply-templates select="child::node()">
267                 <xsl:with-param name="mixed" select="true()" />
268             </xsl:apply-templates>
269         </p>
270     </xsl:template>    
271     
272     <xsl:template match="motto_podpis" />
273     
274     
275
276     <!--
277         Tagi obejmujące listę osób poprzedzającą tekst dramatu
278           (zwykle składaną na osobnej stronie; to odmiana stylu listy):
279
280         <lista_osob> osoby </lista_osob>
281     -->
282     <xsl:template match="lista_osob">
283         <xsl:param name="mixed" />
284         <div>
285             <xsl:call-template name="standard-attributes" />
286             <xsl:apply-templates select="child::node()">
287                 <xsl:with-param name="mixed" select="false()" />
288             </xsl:apply-templates>
289         </div>
290     </xsl:template>
291
292     <xsl:template match="naglowek_listy">
293         <xsl:param name="mixed" />
294         <p x-editable="true">
295             <xsl:call-template name="standard-attributes" />
296             <xsl:call-template name="context-menu" />
297             <xsl:apply-templates select="child::node()">
298                 <xsl:with-param name="mixed" select="true()" />
299             </xsl:apply-templates>
300         </p>
301     </xsl:template>
302
303     <xsl:template match="lista_osoba">
304         <xsl:param name="mixed" />
305         <p x-editable="true">
306             <xsl:call-template name="standard-attributes" />
307             <xsl:call-template name="context-menu" />
308             <xsl:apply-templates select="child::node()">
309                 <xsl:with-param name="mixed" select="true()" />
310             </xsl:apply-templates>
311         </p>
312     </xsl:template>
313
314     <!--  Tagi obejmujące inne komentarze wprowadzające
315         przed tekstem dramatu (składane razem z listą osób):
316
317         <miejsce_czas> komentarze-wprowadzające </miejsce_czas>
318     -->
319     <xsl:template match="miejsce_czas">
320         <xsl:param name="mixed" />
321         <p x-editable="true">
322             <xsl:call-template name="standard-attributes" />
323             <xsl:call-template name="context-menu" />
324             <xsl:apply-templates select="child::node()">
325                 <xsl:with-param name="mixed" select="true()" />
326             </xsl:apply-templates>
327         </p>
328     </xsl:template>
329
330
331     <!--
332         ***************************
333         TAGI STYLÓW TEKSTU GŁÓWNEGO
334         ***************************
335     -->
336
337     <!--
338       Tagi nagłówka części/księgi:
339       <naglowek_czesc> nagłówek-części-lub-księgi </naglowek_czesc>
340     -->
341     <xsl:template match="naglowek_czesc">
342         <xsl:param name="mixed" />
343         <h2 x-editable="true">
344             <xsl:call-template name="standard-attributes" />
345             <xsl:call-template name="context-menu" />
346             <xsl:apply-templates select="child::node()">
347                 <xsl:with-param name="mixed" select="true()" />
348             </xsl:apply-templates>
349         </h2>
350     </xsl:template>
351
352     <!--
353       Tagi tytułu rozdziału:
354       <naglowek_rozdzial> nr-i/lub-tytuł </naglowek_rozdzial>
355     -->
356     <xsl:template match="naglowek_rozdzial">
357         <xsl:param name="mixed" />
358         <h3 x-editable="true">
359             <xsl:call-template name="standard-attributes" />
360             <xsl:call-template name="context-menu" />
361             <xsl:apply-templates select="child::node()">
362                 <xsl:with-param name="mixed" select="true()" />
363             </xsl:apply-templates>
364         </h3>
365     </xsl:template>
366
367     <!--
368       Tagi tytułu podrozdziału:
369       <naglowek_podrozdzial> nr-i/lub-podtytuł </naglowek_podrozdzial>
370     -->
371     <xsl:template match="naglowek_podrozdzial">
372         <xsl:param name="mixed" />
373         <h4 x-editable="true">
374             <xsl:call-template name="standard-attributes" />
375             <xsl:call-template name="context-menu" />
376             <xsl:apply-templates select="child::node()">
377                 <xsl:with-param name="mixed" select="true()" />
378             </xsl:apply-templates>
379         </h4>
380     </xsl:template>
381
382     <!--
383        Tagi sródtytułu:
384        <srodtytul> śródtytuł </srodtytul>
385
386        Tagi nagłówków aktów:
387        <naglowek_akt> nagłówek-aktu </naglowek_akt>
388     -->
389
390     <xsl:template match="srodtytul">
391         <xsl:param name="mixed" />
392         <h2 x-editable="true">
393             <xsl:call-template name="standard-attributes" />
394             <xsl:call-template name="context-menu" />
395             <xsl:apply-templates select="child::node()">
396                 <xsl:with-param name="mixed" select="true()" />
397             </xsl:apply-templates>
398         </h2>
399     </xsl:template>
400
401     <xsl:template match="naglowek_akt">
402         <xsl:param name="mixed" />
403         <h2 x-editable="true">
404             <xsl:call-template name="standard-attributes" />
405             <xsl:call-template name="context-menu" />
406             <xsl:apply-templates select="child::node()">
407                 <xsl:with-param name="mixed" select="true()" />
408             </xsl:apply-templates>
409         </h2>
410     </xsl:template>
411
412     <!--
413       Tagi nagłówków scen:
414       <naglowek_scena> nagłówek-sceny </naglowek_scena>
415     -->
416
417     <xsl:template match="naglowek_scena">
418         <xsl:param name="mixed" />
419         <h3 x-editable="true">
420             <xsl:call-template name="standard-attributes" />
421             <xsl:call-template name="context-menu" />
422             <xsl:apply-templates select="child::node()">
423                 <xsl:with-param name="mixed" select="true()" />
424             </xsl:apply-templates>
425         </h3>
426     </xsl:template>
427     
428     <xsl:template match="naglowek_osoba">
429         <xsl:param name="mixed" />
430         <h4 x-editable="true">
431             <xsl:call-template name="standard-attributes" />
432             <xsl:call-template name="context-menu" />
433             <xsl:apply-templates select="child::node()">
434                 <xsl:with-param name="mixed" select="true()" />
435             </xsl:apply-templates>
436         </h4>
437     </xsl:template>
438
439     <!--
440        ************************
441        Bloki w tekście głównym
442        ************************
443     -->
444     
445     <xsl:template match="dlugi_cytat">
446         <xsl:param name="mixed" />
447         <div>
448             <xsl:call-template name="standard-attributes" />
449             <xsl:apply-templates select="child::node()">
450                 <xsl:with-param name="mixed" select="false()" />
451             </xsl:apply-templates>
452         </div>
453     </xsl:template>
454     
455     <xsl:template match="poezja_cyt">
456         <xsl:param name="mixed" />
457         <div>
458             <xsl:call-template name="standard-attributes" />
459             <xsl:apply-templates select="child::node()">
460                 <xsl:with-param name="mixed" select="false()" />
461             </xsl:apply-templates>
462         </div>
463     </xsl:template>
464
465     <xsl:template match="kwestia">
466         <xsl:param name="mixed" />
467         <div>
468             <xsl:call-template name="standard-attributes" />
469             <xsl:apply-templates select="child::node()">
470                 <xsl:with-param name="mixed" select="false()" />
471             </xsl:apply-templates>
472         </div>
473     </xsl:template>
474
475     <xsl:template match="didaskalia">
476         <xsl:param name="mixed" />
477         <div x-editable="true">
478             <xsl:call-template name="standard-attributes" />
479             <xsl:apply-templates select="child::node()">
480                 <xsl:with-param name="mixed" select="true()" />
481             </xsl:apply-templates>
482         </div>
483     </xsl:template>
484
485     <xsl:template match="wywiad_pyt">
486         <xsl:param name="mixed" />
487         <div>
488             <xsl:call-template name="standard-attributes" />
489             <xsl:apply-templates select="child::node()">
490                 <xsl:with-param name="mixed" select="false()" />
491             </xsl:apply-templates>
492         </div>
493     </xsl:template>
494
495     <xsl:template match="wywiad_odp">
496         <xsl:param name="mixed" />
497         <div>
498             <xsl:call-template name="standard-attributes" />
499             <xsl:apply-templates select="child::node()">
500                 <xsl:with-param name="mixed" select="false()" />
501             </xsl:apply-templates>
502         </div>
503     </xsl:template>
504
505     <!--
506         ***********************************
507         Style akapitowe oraz strofy i wersy
508         ***********************************
509     -->
510
511     <xsl:template match="akap">
512         <xsl:param name="mixed" />
513         <p x-editable="true">
514             <xsl:call-template name="standard-attributes" />
515             <xsl:call-template name="context-menu" />
516             <xsl:apply-templates select="child::node()">
517                 <xsl:with-param name="mixed" select="true()" />
518             </xsl:apply-templates>
519         </p>
520     </xsl:template>
521
522     <xsl:template match="akap_cd">
523         <xsl:param name="mixed" />
524         <p x-editable="true">
525             <xsl:call-template name="standard-attributes" />
526             <xsl:call-template name="context-menu" />
527             <xsl:apply-templates select="child::node()">
528                 <xsl:with-param name="mixed" select="true()" />
529             </xsl:apply-templates>
530         </p>
531     </xsl:template>
532
533     <xsl:template match="akap_dialog">
534         <xsl:param name="mixed" />
535         <p x-editable="true">
536             <xsl:call-template name="standard-attributes" />
537             <xsl:call-template name="context-menu" />
538             <xsl:apply-templates select="child::node()">
539                 <xsl:with-param name="mixed" select="true()" />
540             </xsl:apply-templates>
541         </p>
542     </xsl:template>
543
544     <!--
545         ********
546         STROFA
547         ********
548     -->
549     <xsl:template match="strofa">
550         <div x-editable="true">
551             <xsl:call-template name="standard-attributes" />
552             <xsl:call-template name="context-menu" />
553          
554             <xsl:choose>
555                 <xsl:when test="count(br) > 0">
556                     <xsl:variable name="first-verse" select="br[1]/preceding-sibling::node()" />                    
557                     <xsl:call-template name="verse">
558                         <xsl:with-param name="verse-content" select="$first-verse" />                        
559                     </xsl:call-template>
560                     <xsl:for-each select="br">
561                         <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
562                         <!-- select all nodes up to the next br or end of stanza -->
563                         <xsl:variable name="current-verse"
564                             select="following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />                        
565                         <xsl:call-template name="verse">
566                             <xsl:with-param name="verse-content" select="$current-verse" />                            
567                         </xsl:call-template>
568                     </xsl:for-each>
569                 </xsl:when>
570                 <xsl:otherwise>
571                     <xsl:call-template name="verse">
572                         <xsl:with-param name="verse-content" select="child::node()" />                        
573                     </xsl:call-template>
574                 </xsl:otherwise>
575             </xsl:choose>
576         </div>
577     </xsl:template>
578
579     <xsl:template name="verse">
580         <!-- the verse contents including the last br (if any) -->
581         <xsl:param name="verse-content" />
582         <xsl:variable name="first-tag-name" select="name($verse-content/self::*)" />
583         <!-- name of text nodes is '' == false -->
584
585         <!-- THIS IS A HORROR!!! -->
586         <!-- Possible variants: -->
587         <xsl:choose>
588             <!-- Simple verse == not wers_ tags anywhere until the ending br -->
589             <xsl:when test="not($verse-content[starts-with(name(), 'wers')])">
590                 <p class="wers" x-node="wers" x-verse="true" x-auto-node="true">
591                 <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
592                     <xsl:with-param name="mixed" select="true()" />
593                 </xsl:apply-templates>
594                 </p>
595             </xsl:when>
596
597             <xsl:otherwise>
598             <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
599                 <xsl:with-param name="mixed" select="false()" />
600             </xsl:apply-templates>
601             </xsl:otherwise>
602         </xsl:choose>
603     </xsl:template>
604
605     <xsl:template match="wers_cd|wers_akap|wers_wciety|wers_do_prawej|wers">
606         <xsl:param name="mixed" />
607                 <!-- <xsl:choose>
608                 <xsl:when test="ancestor::*[0]/self::strofa"> -->
609                 <p x-verse="true">
610                 <xsl:call-template name="standard-attributes" />
611                 <xsl:apply-templates select="child::node()">
612                         <xsl:with-param name="mixed" select="true()" />
613                 </xsl:apply-templates>
614                 </p>
615                 <!-- </xsl:when> 
616                 <xsl:choose> -->
617     </xsl:template>
618
619     <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
620
621
622     <!--
623         *************
624         STYLE ZNAKOWE
625         *************
626     -->
627
628     <!--
629         Tagi obejmujące tytuł dzieła, np. książki, filmu, piosenki,
630         modlitwy, przedstawienia teatr. itd.:
631
632         <tytul_dziela> tytuł-dzieła </tytul_dziela>
633     -->
634     <xsl:template match="tytul_dziela">
635         <xsl:param name="mixed" />
636         <em>
637             <xsl:call-template name="standard-attributes" />
638             <xsl:apply-templates select="child::node()">
639                 <xsl:with-param name="mixed" select="true()" />
640             </xsl:apply-templates>
641         </em>
642     </xsl:template>
643
644     <xsl:template match="wyroznienie|slowo_obce|mat|didask_tekst|osoba|wyp_osoba|www|wieksze_odstepy">
645         <xsl:param name="mixed" />
646         <em>
647             <xsl:call-template name="standard-attributes" />
648             <xsl:apply-templates select="child::node()">
649                 <xsl:with-param name="mixed" select="true()" />
650             </xsl:apply-templates>
651         </em>
652     </xsl:template>
653
654     <xsl:template match="indeks_dolny">
655         <xsl:param name="mixed" />
656         <sub>
657             <xsl:call-template name="standard-attributes" />
658             <xsl:apply-templates select="child::node()">
659                 <xsl:with-param name="mixed" select="true()" />
660             </xsl:apply-templates>
661         </sub>
662     </xsl:template>
663
664     <!--
665         **********
666         SEPARATORY
667         **********
668     -->
669     <xsl:template match="sekcja_swiatlo">
670         <xsl:param name="mixed" />
671         <hr><xsl:call-template name="standard-attributes" /></hr>
672     </xsl:template>
673
674     <xsl:template match="sekcja_asterysk">
675         <xsl:param name="mixed" />
676         <p><xsl:call-template name="standard-attributes" /></p>
677     </xsl:template>
678
679     <xsl:template match="separator_linia">
680         <xsl:param name="mixed" />
681         <hr><xsl:call-template name="standard-attributes" /></hr>
682     </xsl:template>
683
684     <xsl:template match="zastepnik_wersu">
685         <xsl:param name="mixed" />
686         <span>
687             <xsl:call-template name="standard-attributes" />
688             <xsl:apply-templates select="child::node()">
689                 <xsl:with-param name="mixed" select="true()" />
690             </xsl:apply-templates>
691         </span>
692     </xsl:template>
693
694     <!--
695         *************
696            PRZYPISY
697         *************
698     -->
699
700     <!--
701         Przypisy i motywy
702     -->
703     <xsl:template match="pr|pa|pe|pt">       
704         <span x-editable="true" x-common="common">
705             <xsl:call-template name="standard-attributes">
706                 <xsl:with-param name="extra-class" select="'annotation-inline-box'" />
707             </xsl:call-template>
708             <a name="anchor-{generate-id(.)}" />
709             <!-- the link to the non-inline version -->
710             <a href="#annotation-{generate-id(.)}" class="annotation"></a>
711             <!-- inline contents -->
712             <span x-annotation-box="true" x-pass-thru="true">
713                 <xsl:call-template name="context-menu" />
714                 <xsl:apply-templates select="node()">
715                     <xsl:with-param name="mixed" select="true()" />
716                 </xsl:apply-templates>
717             </span>
718         </span>
719     </xsl:template>
720
721     <xsl:template match="begin">        
722         <span>
723             <xsl:call-template name="standard-attributes" />
724             <xsl:attribute name="theme-class">
725                 <xsl:value-of select="substring-after(@id, 'b')" />
726             </xsl:attribute>
727         </span>
728     </xsl:template>
729
730     <xsl:template match="extra|uwaga">
731         <span x-common="common">
732             <xsl:call-template name="standard-attributes" />
733             <xsl:apply-templates select="child::node()">
734                 <xsl:with-param name="mixed" select="true()" />
735             </xsl:apply-templates>
736         </span>
737     </xsl:template>
738
739     <xsl:template match="motyw">
740         <span x-editable="true" x-common="common">
741             <xsl:call-template name="standard-attributes" />
742             <xsl:attribute name="theme-class">
743                 <xsl:value-of select="substring-after(@id, 'm')" />
744             </xsl:attribute>
745             <xsl:call-template name="context-menu" />
746             <span x-pass-thru="true" class="theme-text-list"><xsl:value-of select=".|node()" /></span>
747         </span>
748     </xsl:template>
749
750     <xsl:template match="end">
751         <span>
752             <xsl:call-template name="standard-attributes" />
753             <xsl:attribute name="theme-class">
754                 <xsl:value-of select="substring-after(@id, 'e')" />
755             </xsl:attribute>
756         </span>
757     </xsl:template>
758
759
760     <!--
761         ****************
762          TEKST WŁAŚCIWY
763         ****************
764     -->
765
766     <xsl:template match="text()">
767         <!-- <xsl:value-of select="." /> -->
768         <xsl:param name="mixed" />
769         <xsl:choose>
770             <xsl:when test="normalize-space(.) = ''">
771                 <xsl:value-of select="." />
772             </xsl:when>
773             <xsl:when test="not($mixed)">
774                 <span x-node="out-of-flow-text" class="out-of-flow-text" x-editable="true">
775                         <xsl:value-of select="." />
776                                 </span>
777                         </xsl:when>
778             <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
779         </xsl:choose>
780     </xsl:template>
781
782     <xsl:template match="comment()">
783         <xsl:comment><xsl:value-of select="." /></xsl:comment>
784     </xsl:template>
785
786     <xsl:template match="*[name() != local-name()]">
787         <span>
788             <xsl:call-template name="standard-attributes" />
789             <xsl:apply-templates select="child::node()">
790                 <xsl:with-param name="mixed" select="true()" />
791             </xsl:apply-templates>
792         </span>
793     </xsl:template>
794         
795         <!-- 
796                 Earlier versions of html2wl introduced a BUG, that 'causes "out-of-flow-text" tag to appear.
797                 Instead of marking it as "unknown", just pass thru it.
798                 Keep a pass-thru span for out-of-flow box editing
799         -->
800     <xsl:template match="out-of-flow-text">
801         <span data-pass-thru="true">
802             <xsl:apply-templates select="child::node()">
803                 <xsl:with-param name="mixed" select="false()" />
804             </xsl:apply-templates>        
805         </span>
806     </xsl:template>
807
808     <xsl:template match="*">
809         <span>
810             <xsl:call-template name="standard-attributes">
811                 <xsl:with-param name="extra-class">unknown-tag</xsl:with-param>
812             </xsl:call-template>
813             <xsl:apply-templates select="child::node()">
814                 <xsl:with-param name="mixed" select="true()" />
815             </xsl:apply-templates>        
816         </span>
817     </xsl:template>
818
819     <xsl:template name="context-menu">
820         <!-- <span class="default-menu context-menu"> -->
821         <!-- <button class="edit-button">Edytuj</button> -->
822             <!-- <span class="delete-button">Delete</span> -->
823         <!-- </span> -->
824         <!-- <span class="edit-menu context-menu">
825             <span class="accept-button">Accept</span>
826             <span class="reject-button">Close</span>
827         </span> -->
828     </xsl:template>
829
830     <xsl:template name="standard-attributes">
831         <xsl:param name="extra-class" />
832         <xsl:attribute name="class"><xsl:value-of select="local-name()" /><xsl:text>&#x0020;</xsl:text><xsl:value-of select="$extra-class" /></xsl:attribute>
833
834         <xsl:attribute name="x-node"><xsl:value-of select="local-name()" /></xsl:attribute>
835
836         <xsl:if test="local-name() != name()">
837             <xsl:attribute name="x-ns"><xsl:value-of select="namespace-uri()" /></xsl:attribute>
838         </xsl:if>
839
840         <xsl:for-each select="@*">
841             <xsl:variable name="id" select="generate-id()" />
842             <xsl:attribute name="x-attr-value-{$id}"><xsl:value-of select="."/></xsl:attribute>
843             <xsl:attribute name="x-attr-name-{$id}"><xsl:value-of select="local-name()"/></xsl:attribute>
844             <xsl:choose>
845                 <xsl:when test="namespace-uri()">
846                 <xsl:attribute name="x-attr-ns-{$id}"><xsl:value-of select="namespace-uri()"/></xsl:attribute>
847                                 </xsl:when>
848                                 <!-- if the element belongs to default namespace and attribut has no namespace -->
849                 <xsl:when test="not(namespace-uri(.))">
850                                 <xsl:attribute name="data-wlf-{local-name()}"><xsl:value-of select="."/></xsl:attribute>
851                                 </xsl:when>
852                         </xsl:choose>               
853         </xsl:for-each>
854     </xsl:template>
855
856     <xsl:template match="alien">
857             <span class="alien" x-pass-thru="true">
858                 <xsl:apply-templates select="node()">
859                     <xsl:with-param name="mixed" select="true()" />
860                 </xsl:apply-templates>
861             </span>
862     </xsl:template>
863
864     <xsl:template match="comment()">
865         <xsl:comment><xsl:value-of select="."/></xsl:comment>
866     </xsl:template>
867 </xsl:stylesheet>