Fixes #4204: use div instead of p in visual editor to prevent nesting issues.
[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         <div 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         </div>
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         <div 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         </div>
301     </xsl:template>
302
303     <xsl:template match="lista_osoba">
304         <xsl:param name="mixed" />
305         <div 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         </div>
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         <div 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         </div>
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     <xsl:template match="ilustr">
506       <div>
507         <xsl:call-template name="standard-attributes" />
508         <img>
509           <xsl:attribute name="src">
510             <xsl:value-of select="@src" />
511           </xsl:attribute>
512         </img>
513         <p class="alt"><xsl:value-of select="@alt"/></p>
514       </div>
515     </xsl:template>
516
517     <!--
518         ***********************************
519         Style akapitowe oraz strofy i wersy
520         ***********************************
521     -->
522
523     <xsl:template match="akap">
524         <xsl:param name="mixed" />
525         <div x-editable="true">
526             <xsl:call-template name="standard-attributes" />
527             <xsl:call-template name="context-menu" />
528             <xsl:apply-templates select="child::node()">
529                 <xsl:with-param name="mixed" select="true()" />
530             </xsl:apply-templates>
531         </div>
532     </xsl:template>
533
534     <xsl:template match="akap_cd">
535         <xsl:param name="mixed" />
536         <div x-editable="true">
537             <xsl:call-template name="standard-attributes" />
538             <xsl:call-template name="context-menu" />
539             <xsl:apply-templates select="child::node()">
540                 <xsl:with-param name="mixed" select="true()" />
541             </xsl:apply-templates>
542         </div>
543     </xsl:template>
544
545     <xsl:template match="akap_dialog">
546         <xsl:param name="mixed" />
547         <div x-editable="true">
548             <xsl:call-template name="standard-attributes" />
549             <xsl:call-template name="context-menu" />
550             <xsl:apply-templates select="child::node()">
551                 <xsl:with-param name="mixed" select="true()" />
552             </xsl:apply-templates>
553         </div>
554     </xsl:template>
555
556     <!--
557         ********
558         STROFA
559         ********
560     -->
561     <xsl:template match="strofa">
562         <div x-editable="true">
563             <xsl:call-template name="standard-attributes" />
564             <xsl:call-template name="context-menu" />
565          
566             <xsl:choose>
567                 <xsl:when test="count(br) > 0">
568                     <xsl:variable name="first-verse" select="br[1]/preceding-sibling::node()" />                    
569                     <xsl:call-template name="verse">
570                         <xsl:with-param name="verse-content" select="$first-verse" />                        
571                     </xsl:call-template>
572                     <xsl:for-each select="br">
573                         <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
574                         <!-- select all nodes up to the next br or end of stanza -->
575                         <xsl:variable name="current-verse"
576                             select="following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />                        
577                         <xsl:call-template name="verse">
578                             <xsl:with-param name="verse-content" select="$current-verse" />                            
579                         </xsl:call-template>
580                     </xsl:for-each>
581                 </xsl:when>
582                 <xsl:otherwise>
583                     <xsl:call-template name="verse">
584                         <xsl:with-param name="verse-content" select="child::node()" />                        
585                     </xsl:call-template>
586                 </xsl:otherwise>
587             </xsl:choose>
588         </div>
589     </xsl:template>
590
591     <xsl:template name="verse">
592         <!-- the verse contents including the last br (if any) -->
593         <xsl:param name="verse-content" />
594         <xsl:variable name="first-tag-name" select="name($verse-content/self::*)" />
595         <!-- name of text nodes is '' == false -->
596
597         <!-- THIS IS A HORROR!!! -->
598         <!-- Possible variants: -->
599         <xsl:choose>
600             <!-- Simple verse == not wers_ tags anywhere until the ending br -->
601             <xsl:when test="not($verse-content[starts-with(name(), 'wers')])">
602                 <div class="wers" x-node="wers" x-verse="true" x-auto-node="true">
603                 <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
604                     <xsl:with-param name="mixed" select="true()" />
605                 </xsl:apply-templates>
606                 </div>
607             </xsl:when>
608
609             <xsl:otherwise>
610             <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
611                 <xsl:with-param name="mixed" select="false()" />
612             </xsl:apply-templates>
613             </xsl:otherwise>
614         </xsl:choose>
615     </xsl:template>
616
617     <xsl:template match="wers_cd|wers_akap|wers_wciety|wers_do_prawej|wers">
618         <xsl:param name="mixed" />
619                 <!-- <xsl:choose>
620                 <xsl:when test="ancestor::*[0]/self::strofa"> -->
621                 <div x-verse="true">
622                 <xsl:call-template name="standard-attributes" />
623                 <xsl:apply-templates select="child::node()">
624                         <xsl:with-param name="mixed" select="true()" />
625                 </xsl:apply-templates>
626                 </div>
627                 <!-- </xsl:when> 
628                 <xsl:choose> -->
629     </xsl:template>
630
631     <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
632
633
634     <!--
635         *************
636         STYLE ZNAKOWE
637         *************
638     -->
639
640     <!--
641         Tagi obejmujące tytuł dzieła, np. książki, filmu, piosenki,
642         modlitwy, przedstawienia teatr. itd.:
643
644         <tytul_dziela> tytuł-dzieła </tytul_dziela>
645     -->
646     <xsl:template match="tytul_dziela">
647         <xsl:param name="mixed" />
648         <em>
649             <xsl:call-template name="standard-attributes" />
650             <xsl:apply-templates select="child::node()">
651                 <xsl:with-param name="mixed" select="true()" />
652             </xsl:apply-templates>
653         </em>
654     </xsl:template>
655
656     <xsl:template match="wyroznienie|slowo_obce|mat|didask_tekst|osoba|wyp_osoba|www|wieksze_odstepy">
657         <xsl:param name="mixed" />
658         <em>
659             <xsl:call-template name="standard-attributes" />
660             <xsl:apply-templates select="child::node()">
661                 <xsl:with-param name="mixed" select="true()" />
662             </xsl:apply-templates>
663         </em>
664     </xsl:template>
665
666     <xsl:template match="indeks_dolny">
667         <xsl:param name="mixed" />
668         <sub>
669             <xsl:call-template name="standard-attributes" />
670             <xsl:apply-templates select="child::node()">
671                 <xsl:with-param name="mixed" select="true()" />
672             </xsl:apply-templates>
673         </sub>
674     </xsl:template>
675
676     <!--
677         **********
678         SEPARATORY
679         **********
680     -->
681     <xsl:template match="sekcja_swiatlo">
682         <xsl:param name="mixed" />
683         <hr><xsl:call-template name="standard-attributes" /></hr>
684     </xsl:template>
685
686     <xsl:template match="sekcja_asterysk">
687         <xsl:param name="mixed" />
688         <div><xsl:call-template name="standard-attributes" /></div>
689     </xsl:template>
690
691     <xsl:template match="separator_linia">
692         <xsl:param name="mixed" />
693         <hr><xsl:call-template name="standard-attributes" /></hr>
694     </xsl:template>
695
696     <xsl:template match="zastepnik_wersu">
697         <xsl:param name="mixed" />
698         <span>
699             <xsl:call-template name="standard-attributes" />
700             <xsl:apply-templates select="child::node()">
701                 <xsl:with-param name="mixed" select="true()" />
702             </xsl:apply-templates>
703         </span>
704     </xsl:template>
705
706     <!--
707         *************
708            PRZYPISY
709         *************
710     -->
711
712     <!--
713         Przypisy i motywy
714     -->
715     <xsl:template match="pr|pa|pe|pt">       
716         <span x-editable="true" x-common="common">
717             <xsl:call-template name="standard-attributes">
718                 <xsl:with-param name="extra-class" select="'annotation-inline-box'" />
719             </xsl:call-template>
720             <a name="anchor-{generate-id(.)}" />
721             <!-- the link to the non-inline version -->
722             <a href="#annotation-{generate-id(.)}" class="annotation"></a>
723             <!-- inline contents -->
724             <span x-annotation-box="true" x-pass-thru="true">
725                 <xsl:call-template name="context-menu" />
726                 <xsl:apply-templates select="node()">
727                     <xsl:with-param name="mixed" select="true()" />
728                 </xsl:apply-templates>
729             </span>
730         </span>
731     </xsl:template>
732
733     <xsl:template match="ref">
734       <span x-editable="true" x-common="common" x-edit-no-format="true" x-edit-attribute="href">
735         <xsl:call-template name="standard-attributes">
736           <xsl:with-param name="extra-class" select="'reference-inline-box'" />
737         </xsl:call-template>
738         <a class="reference">📌</a>
739       </span>
740     </xsl:template>
741     
742     <xsl:template match="begin">        
743         <span>
744             <xsl:call-template name="standard-attributes" />
745             <xsl:attribute name="theme-class">
746                 <xsl:value-of select="substring-after(@id, 'b')" />
747             </xsl:attribute>
748         </span>
749     </xsl:template>
750
751     <xsl:template match="extra|uwaga">
752         <span x-common="common">
753             <xsl:call-template name="standard-attributes" />
754             <xsl:apply-templates select="child::node()">
755                 <xsl:with-param name="mixed" select="true()" />
756             </xsl:apply-templates>
757         </span>
758     </xsl:template>
759
760     <xsl:template match="motyw">
761         <span x-editable="true" x-edit-no-format="true" x-common="common">
762             <xsl:call-template name="standard-attributes" />
763             <xsl:attribute name="theme-class">
764                 <xsl:value-of select="substring-after(@id, 'm')" />
765             </xsl:attribute>
766             <xsl:call-template name="context-menu" />
767             <span x-pass-thru="true" class="theme-text-list"><xsl:value-of select=".|node()" /></span>
768         </span>
769     </xsl:template>
770
771     <xsl:template match="end">
772         <span>
773             <xsl:call-template name="standard-attributes" />
774             <xsl:attribute name="theme-class">
775                 <xsl:value-of select="substring-after(@id, 'e')" />
776             </xsl:attribute>
777         </span>
778     </xsl:template>
779
780
781     <!--
782         ****************
783          TEKST WŁAŚCIWY
784         ****************
785     -->
786
787     <xsl:template match="text()">
788         <!-- <xsl:value-of select="." /> -->
789         <xsl:param name="mixed" />
790         <xsl:choose>
791             <xsl:when test="normalize-space(.) = ''">
792                 <xsl:value-of select="." />
793             </xsl:when>
794             <xsl:when test="not($mixed)">
795                 <span x-node="out-of-flow-text" class="out-of-flow-text" x-editable="true">
796                         <xsl:value-of select="." />
797                                 </span>
798                         </xsl:when>
799             <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
800         </xsl:choose>
801     </xsl:template>
802
803     <xsl:template match="comment()">
804         <xsl:comment><xsl:value-of select="." /></xsl:comment>
805     </xsl:template>
806
807     <xsl:template match="*[name() != local-name()]">
808         <span>
809             <xsl:call-template name="standard-attributes" />
810             <xsl:apply-templates select="child::node()">
811                 <xsl:with-param name="mixed" select="true()" />
812             </xsl:apply-templates>
813         </span>
814     </xsl:template>
815         
816         <!-- 
817                 Earlier versions of html2wl introduced a BUG, that 'causes "out-of-flow-text" tag to appear.
818                 Instead of marking it as "unknown", just pass thru it.
819                 Keep a pass-thru span for out-of-flow box editing
820         -->
821     <xsl:template match="out-of-flow-text">
822         <span data-pass-thru="true">
823             <xsl:apply-templates select="child::node()">
824                 <xsl:with-param name="mixed" select="false()" />
825             </xsl:apply-templates>        
826         </span>
827     </xsl:template>
828
829     <xsl:template match="*">
830         <span>
831             <xsl:call-template name="standard-attributes">
832                 <xsl:with-param name="extra-class">unknown-tag</xsl:with-param>
833             </xsl:call-template>
834             <xsl:apply-templates select="child::node()">
835                 <xsl:with-param name="mixed" select="true()" />
836             </xsl:apply-templates>        
837         </span>
838     </xsl:template>
839
840     <xsl:template name="context-menu">
841         <!-- <span class="default-menu context-menu"> -->
842         <!-- <button class="edit-button">Edytuj</button> -->
843             <!-- <span class="delete-button">Delete</span> -->
844         <!-- </span> -->
845         <!-- <span class="edit-menu context-menu">
846             <span class="accept-button">Accept</span>
847             <span class="reject-button">Close</span>
848         </span> -->
849     </xsl:template>
850
851     <xsl:template name="standard-attributes">
852         <xsl:param name="extra-class" />
853         <xsl:attribute name="class"><xsl:value-of select="local-name()" /><xsl:text>&#x0020;</xsl:text><xsl:value-of select="$extra-class" /></xsl:attribute>
854
855         <xsl:attribute name="x-node"><xsl:value-of select="local-name()" /></xsl:attribute>
856
857         <xsl:if test="local-name() != name()">
858             <xsl:attribute name="x-ns"><xsl:value-of select="namespace-uri()" /></xsl:attribute>
859         </xsl:if>
860
861         <xsl:for-each select="@*">
862             <xsl:variable name="id" select="generate-id()" />
863             <xsl:attribute name="x-attr-value-{$id}"><xsl:value-of select="."/></xsl:attribute>
864             <xsl:attribute name="x-attr-name-{$id}"><xsl:value-of select="local-name()"/></xsl:attribute>
865             <xsl:choose>
866                 <xsl:when test="namespace-uri()">
867                 <xsl:attribute name="x-attr-ns-{$id}"><xsl:value-of select="namespace-uri()"/></xsl:attribute>
868                                 </xsl:when>
869                                 <!-- if the element belongs to default namespace and attribut has no namespace -->
870                 <xsl:when test="not(namespace-uri(.))">
871                                 <xsl:attribute name="data-wlf-{local-name()}"><xsl:value-of select="."/></xsl:attribute>
872                                 </xsl:when>
873                         </xsl:choose>               
874         </xsl:for-each>
875     </xsl:template>
876
877     <xsl:template match="alien">
878             <span class="alien" x-pass-thru="true">
879                 <xsl:apply-templates select="node()">
880                     <xsl:with-param name="mixed" select="true()" />
881                 </xsl:apply-templates>
882             </span>
883     </xsl:template>
884
885     <xsl:template match="comment()">
886         <xsl:comment><xsl:value-of select="."/></xsl:comment>
887     </xsl:template>
888 </xsl:stylesheet>