* Readonly document view.
[redakcja.git] / platforma / 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     <!--
193         Tagi obejmujące tekst dedykacji (styl wieloakapitowy bądź wielostrofowy):
194         <dedykacja> tekst-dedykacji </dedykacja>
195     -->
196     <xsl:template match="dedykacja">
197         <xsl:param name="mixed" />
198         <div>
199             <xsl:call-template name="standard-attributes" />
200             <xsl:apply-templates select="child::node()">
201                 <xsl:with-param name="mixed" select="false()" />
202             </xsl:apply-templates>
203         </div>
204     </xsl:template>
205
206     <!--
207         Tagi obejmujące tekst motta (styl wieloakapitowy bądź wielostrofowy):
208         <motto> tekst-motta </motto>
209     -->
210     <xsl:template match="motto">
211         <xsl:param name="mixed" />
212         <div class="motto_container">
213         <div x-editable="true">
214             <xsl:call-template name="standard-attributes" />
215             <xsl:apply-templates select="child::node()">
216                 <xsl:with-param name="mixed" select="true()" />
217             </xsl:apply-templates>            
218         </div>
219         <xsl:apply-templates select="following-sibling::*[1][self::motto_podpis]" mode="motto">
220             <xsl:with-param name="mixed" select="true()" />
221         </xsl:apply-templates>
222         </div>
223     </xsl:template>
224
225     <!--  
226         Catch stand-alone "motto_podpis" and make then render properly.
227         If not, editing will fail :(.
228         
229         TODO: Make "motto" & "motto_podpis" one block in edit mode (like strofa) 
230     -->
231     <xsl:template match="motto_podpis[not(preceding-sibling::*[1][self::motto])]">
232         <xsl:apply-templates select="." mode="motto">
233             <xsl:with-param name="mixed" select="true()" />
234         </xsl:apply-templates>
235     </xsl:template>        
236         
237     <xsl:template match="motto_podpis" mode="motto">
238         <xsl:param name="mixed" />
239         <p x-editable="true">
240             <xsl:call-template name="standard-attributes" />
241             <xsl:call-template name="context-menu" />
242             <xsl:apply-templates select="child::node()">
243                 <xsl:with-param name="mixed" select="true()" />
244             </xsl:apply-templates>
245         </p>
246     </xsl:template>    
247     
248     <xsl:template match="motto_podpis" />
249     
250     
251
252     <!--
253         Tagi obejmujące listę osób poprzedzającą tekst dramatu
254           (zwykle składaną na osobnej stronie; to odmiana stylu listy):
255
256         <lista_osob> osoby </lista_osob>
257     -->
258     <xsl:template match="lista_osob">
259         <xsl:param name="mixed" />
260         <div>
261             <xsl:call-template name="standard-attributes" />
262             <xsl:apply-templates select="child::node()">
263                 <xsl:with-param name="mixed" select="false()" />
264             </xsl:apply-templates>
265         </div>
266     </xsl:template>
267
268     <xsl:template match="naglowek_listy">
269         <xsl:param name="mixed" />
270         <p x-editable="true">
271             <xsl:call-template name="standard-attributes" />
272             <xsl:call-template name="context-menu" />
273             <xsl:apply-templates select="child::node()">
274                 <xsl:with-param name="mixed" select="true()" />
275             </xsl:apply-templates>
276         </p>
277     </xsl:template>
278
279     <xsl:template match="lista_osoba">
280         <xsl:param name="mixed" />
281         <p x-editable="true">
282             <xsl:call-template name="standard-attributes" />
283             <xsl:call-template name="context-menu" />
284             <xsl:apply-templates select="child::node()">
285                 <xsl:with-param name="mixed" select="true()" />
286             </xsl:apply-templates>
287         </p>
288     </xsl:template>
289
290     <!--  Tagi obejmujące inne komentarze wprowadzające
291         przed tekstem dramatu (składane razem z listą osób):
292
293         <miejsce_czas> komentarze-wprowadzające </miejsce_czas>
294     -->
295     <xsl:template match="miejsce_czas">
296         <xsl:param name="mixed" />
297         <p x-editable="true">
298             <xsl:call-template name="standard-attributes" />
299             <xsl:call-template name="context-menu" />
300             <xsl:apply-templates select="child::node()">
301                 <xsl:with-param name="mixed" select="true()" />
302             </xsl:apply-templates>
303         </p>
304     </xsl:template>
305
306
307     <!--
308         ***************************
309         TAGI STYLÓW TEKSTU GŁÓWNEGO
310         ***************************
311     -->
312
313     <!--
314       Tagi nagłówka części/księgi:
315       <naglowek_czesc> nagłówek-części-lub-księgi </naglowek_czesc>
316     -->
317     <xsl:template match="naglowek_czesc">
318         <xsl:param name="mixed" />
319         <h2 x-editable="true">
320             <xsl:call-template name="standard-attributes" />
321             <xsl:call-template name="context-menu" />
322             <xsl:apply-templates select="child::node()">
323                 <xsl:with-param name="mixed" select="true()" />
324             </xsl:apply-templates>
325         </h2>
326     </xsl:template>
327
328     <!--
329       Tagi tytułu rozdziału:
330       <naglowek_rozdzial> nr-i/lub-tytuł </naglowek_rozdzial>
331     -->
332     <xsl:template match="naglowek_rozdzial">
333         <xsl:param name="mixed" />
334         <h3 x-editable="true">
335             <xsl:call-template name="standard-attributes" />
336             <xsl:call-template name="context-menu" />
337             <xsl:apply-templates select="child::node()">
338                 <xsl:with-param name="mixed" select="true()" />
339             </xsl:apply-templates>
340         </h3>
341     </xsl:template>
342
343     <!--
344       Tagi tytułu podrozdziału:
345       <naglowek_podrozdzial> nr-i/lub-podtytuł </naglowek_podrozdzial>
346     -->
347     <xsl:template match="naglowek_podrozdzial">
348         <xsl:param name="mixed" />
349         <h4 x-editable="true">
350             <xsl:call-template name="standard-attributes" />
351             <xsl:call-template name="context-menu" />
352             <xsl:apply-templates select="child::node()">
353                 <xsl:with-param name="mixed" select="true()" />
354             </xsl:apply-templates>
355         </h4>
356     </xsl:template>
357
358     <!--
359        Tagi sródtytułu:
360        <srodtytul> śródtytuł </srodtytul>
361
362        Tagi nagłówków aktów:
363        <naglowek_akt> nagłówek-aktu </naglowek_akt>
364     -->
365
366     <xsl:template match="srodtytul">
367         <xsl:param name="mixed" />
368         <h2 x-editable="true">
369             <xsl:call-template name="standard-attributes" />
370             <xsl:call-template name="context-menu" />
371             <xsl:apply-templates select="child::node()">
372                 <xsl:with-param name="mixed" select="true()" />
373             </xsl:apply-templates>
374         </h2>
375     </xsl:template>
376
377     <xsl:template match="naglowek_akt">
378         <xsl:param name="mixed" />
379         <h2 x-editable="true">
380             <xsl:call-template name="standard-attributes" />
381             <xsl:call-template name="context-menu" />
382             <xsl:apply-templates select="child::node()">
383                 <xsl:with-param name="mixed" select="true()" />
384             </xsl:apply-templates>
385         </h2>
386     </xsl:template>
387
388     <!--
389       Tagi nagłówków scen:
390       <naglowek_scena> nagłówek-sceny </naglowek_scena>
391     -->
392
393     <xsl:template match="naglowek_scena">
394         <xsl:param name="mixed" />
395         <h3 x-editable="true">
396             <xsl:call-template name="standard-attributes" />
397             <xsl:call-template name="context-menu" />
398             <xsl:apply-templates select="child::node()">
399                 <xsl:with-param name="mixed" select="true()" />
400             </xsl:apply-templates>
401         </h3>
402     </xsl:template>
403     
404     <xsl:template match="naglowek_osoba">
405         <xsl:param name="mixed" />
406         <h4 x-editable="true">
407             <xsl:call-template name="standard-attributes" />
408             <xsl:call-template name="context-menu" />
409             <xsl:apply-templates select="child::node()">
410                 <xsl:with-param name="mixed" select="true()" />
411             </xsl:apply-templates>
412         </h4>
413     </xsl:template>
414
415     <!--
416        ************************
417        Bloki w tekście głównym
418        ************************
419     -->
420     
421     <xsl:template match="dlugi_cytat">
422         <xsl:param name="mixed" />
423         <div>
424             <xsl:call-template name="standard-attributes" />
425             <xsl:apply-templates select="child::node()">
426                 <xsl:with-param name="mixed" select="false()" />
427             </xsl:apply-templates>
428         </div>
429     </xsl:template>
430     
431     <xsl:template match="poezja_cyt">
432         <xsl:param name="mixed" />
433         <div>
434             <xsl:call-template name="standard-attributes" />
435             <xsl:apply-templates select="child::node()">
436                 <xsl:with-param name="mixed" select="false()" />
437             </xsl:apply-templates>
438         </div>
439     </xsl:template>
440
441     <xsl:template match="kwestia">
442         <xsl:param name="mixed" />
443         <div>
444             <xsl:call-template name="standard-attributes" />
445             <xsl:apply-templates select="child::node()">
446                 <xsl:with-param name="mixed" select="false()" />
447             </xsl:apply-templates>
448         </div>
449     </xsl:template>
450
451     <xsl:template match="didaskalia">
452         <xsl:param name="mixed" />
453         <div x-editable="true">
454             <xsl:call-template name="standard-attributes" />
455             <xsl:apply-templates select="child::node()">
456                 <xsl:with-param name="mixed" select="true()" />
457             </xsl:apply-templates>
458         </div>
459     </xsl:template>
460
461     <xsl:template match="wywiad_pyt">
462         <xsl:param name="mixed" />
463         <div>
464             <xsl:call-template name="standard-attributes" />
465             <xsl:apply-templates select="child::node()">
466                 <xsl:with-param name="mixed" select="false()" />
467             </xsl:apply-templates>
468         </div>
469     </xsl:template>
470
471     <xsl:template match="wywiad_odp">
472         <xsl:param name="mixed" />
473         <div>
474             <xsl:call-template name="standard-attributes" />
475             <xsl:apply-templates select="child::node()">
476                 <xsl:with-param name="mixed" select="false()" />
477             </xsl:apply-templates>
478         </div>
479     </xsl:template>
480
481     <!--
482         ***********************************
483         Style akapitowe oraz strofy i wersy
484         ***********************************
485     -->
486
487     <xsl:template match="akap">
488         <xsl:param name="mixed" />
489         <p x-editable="true">
490             <xsl:call-template name="standard-attributes" />
491             <xsl:call-template name="context-menu" />
492             <xsl:apply-templates select="child::node()">
493                 <xsl:with-param name="mixed" select="true()" />
494             </xsl:apply-templates>
495         </p>
496     </xsl:template>
497
498     <xsl:template match="akap_cd">
499         <xsl:param name="mixed" />
500         <p x-editable="true">
501             <xsl:call-template name="standard-attributes" />
502             <xsl:call-template name="context-menu" />
503             <xsl:apply-templates select="child::node()">
504                 <xsl:with-param name="mixed" select="true()" />
505             </xsl:apply-templates>
506         </p>
507     </xsl:template>
508
509     <xsl:template match="akap_dialog">
510         <xsl:param name="mixed" />
511         <p x-editable="true">
512             <xsl:call-template name="standard-attributes" />
513             <xsl:call-template name="context-menu" />
514             <xsl:apply-templates select="child::node()">
515                 <xsl:with-param name="mixed" select="true()" />
516             </xsl:apply-templates>
517         </p>
518     </xsl:template>
519
520     <!--
521         ********
522         STROFA
523         ********
524     -->
525     <xsl:template match="strofa">
526         <div x-editable="true">
527             <xsl:call-template name="standard-attributes" />
528             <xsl:call-template name="context-menu" />
529          
530             <xsl:choose>
531                 <xsl:when test="count(br) > 0">
532                     <xsl:variable name="first-verse" select="br[1]/preceding-sibling::node()" />                    
533                     <xsl:call-template name="verse">
534                         <xsl:with-param name="verse-content" select="$first-verse" />                        
535                     </xsl:call-template>
536                     <xsl:for-each select="br">
537                         <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
538                         <!-- select all nodes up to the next br or end of stanza -->
539                         <xsl:variable name="current-verse"
540                             select="following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />                        
541                         <xsl:call-template name="verse">
542                             <xsl:with-param name="verse-content" select="$current-verse" />                            
543                         </xsl:call-template>
544                     </xsl:for-each>
545                 </xsl:when>
546                 <xsl:otherwise>
547                     <xsl:call-template name="verse">
548                         <xsl:with-param name="verse-content" select="child::node()" />                        
549                     </xsl:call-template>
550                 </xsl:otherwise>
551             </xsl:choose>
552         </div>
553     </xsl:template>
554
555     <xsl:template name="verse">
556         <!-- the verse contents including the last br (if any) -->
557         <xsl:param name="verse-content" />
558         <xsl:variable name="first-tag-name" select="name($verse-content/self::*)" />
559         <!-- name of text nodes is '' == false -->
560
561         <!-- THIS IS A HORROR!!! -->
562         <!-- Possible variants: -->
563         <xsl:choose>
564             <!-- Simple verse == not wers_ tags anywhere until the ending br -->
565             <xsl:when test="not($verse-content[starts-with(name(), 'wers_')])">
566                 <p class="wers" x-node="wers" x-verse="true">
567                 <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
568                     <xsl:with-param name="mixed" select="true()" />
569                 </xsl:apply-templates>
570                 </p>
571             </xsl:when>
572
573             <xsl:otherwise>
574             <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
575                 <xsl:with-param name="mixed" select="false()" />
576             </xsl:apply-templates>
577             </xsl:otherwise>
578         </xsl:choose>
579     </xsl:template>
580
581     <xsl:template match="wers_cd|wers_akap|wers_wciety">
582         <xsl:param name="mixed" />
583                 <!-- <xsl:choose>
584                 <xsl:when test="ancestor::*[0]/self::strofa"> -->
585                 <p x-verse="true">
586                 <xsl:call-template name="standard-attributes" />
587                 <xsl:apply-templates select="child::node()">
588                         <xsl:with-param name="mixed" select="true()" />
589                 </xsl:apply-templates>
590                 </p>
591                 <!-- </xsl:when> 
592                 <xsl:choose> -->
593     </xsl:template>
594
595     <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
596
597
598     <!--
599         *************
600         STYLE ZNAKOWE
601         *************
602     -->
603
604     <!--
605         Tagi obejmujące tytuł dzieła, np. książki, filmu, piosenki,
606         modlitwy, przedstawienia teatr. itd.:
607
608         <tytul_dziela> tytuł-dzieła </tytul_dziela>
609     -->
610     <xsl:template match="tytul_dziela">
611         <xsl:param name="mixed" />
612         <em>
613             <xsl:call-template name="standard-attributes" />
614             <xsl:apply-templates select="child::node()">
615                 <xsl:with-param name="mixed" select="true()" />
616             </xsl:apply-templates>
617         </em>
618     </xsl:template>
619
620     <xsl:template match="wyroznienie|slowo_obce|mat|didask_tekst|osoba|wyp_osoba|www">
621         <xsl:param name="mixed" />
622         <em>
623             <xsl:call-template name="standard-attributes" />
624             <xsl:apply-templates select="child::node()">
625                 <xsl:with-param name="mixed" select="true()" />
626             </xsl:apply-templates>
627         </em>
628     </xsl:template>
629
630     <!--
631         **********
632         SEPARATORY
633         **********
634     -->
635     <xsl:template match="sekcja_swiatlo">
636         <xsl:param name="mixed" />
637         <br><xsl:call-template name="standard-attributes" /></br>
638     </xsl:template>
639
640     <xsl:template match="sekcja_asterysk">
641         <xsl:param name="mixed" />
642         <hr><xsl:call-template name="standard-attributes" /></hr>
643     </xsl:template>
644
645     <xsl:template match="separator_linia">
646         <xsl:param name="mixed" />
647         <hr><xsl:call-template name="standard-attributes" /></hr>
648     </xsl:template>
649
650     <xsl:template match="zastepnik_wersu">
651         <xsl:param name="mixed" />
652         <hr><xsl:call-template name="standard-attributes" /></hr>
653     </xsl:template>
654
655     <!--
656         *************
657            PRZYPISY
658         *************
659     -->
660
661     <!--
662         Przypisy i motywy
663     -->
664     <xsl:template match="pr|pa|pe|pt">       
665         <span x-editable="true" x-common="common">
666             <xsl:call-template name="standard-attributes">
667                 <xsl:with-param name="extra-class" select="'annotation-inline-box'" />
668             </xsl:call-template>
669             <a name="anchor-{generate-id(.)}" />
670             <!-- the link to the non-inline version -->
671             <a href="#annotation-{generate-id(.)}" class="annotation"></a>
672             <!-- inline contents -->
673             <span x-annotation-box="true" x-pass-thru="true">
674                 <xsl:call-template name="context-menu" />
675                 <xsl:apply-templates select="node()">
676                     <xsl:with-param name="mixed" select="true()" />
677                 </xsl:apply-templates>
678             </span>
679         </span>
680     </xsl:template>
681
682     <xsl:template match="begin">        
683         <span>
684             <xsl:call-template name="standard-attributes" />
685             <xsl:attribute name="theme-class">
686                 <xsl:value-of select="substring-after(@id, 'b')" />
687             </xsl:attribute>
688         </span>
689     </xsl:template>
690
691     <xsl:template match="extra|uwaga">
692         <span x-common="common">
693             <xsl:call-template name="standard-attributes" />
694             <xsl:apply-templates select="child::node()">
695                 <xsl:with-param name="mixed" select="true()" />
696             </xsl:apply-templates>
697         </span>
698     </xsl:template>
699
700     <xsl:template match="motyw">
701         <span x-editable="true" x-common="common">
702             <xsl:call-template name="standard-attributes" />
703             <xsl:attribute name="theme-class">
704                 <xsl:value-of select="substring-after(@id, 'm')" />
705             </xsl:attribute>
706             <xsl:call-template name="context-menu" />
707             <span x-pass-thru="true" class="theme-text-list"><xsl:value-of select=".|node()" /></span>
708         </span>
709     </xsl:template>
710
711     <xsl:template match="end">
712         <span>
713             <xsl:call-template name="standard-attributes" />
714             <xsl:attribute name="theme-class">
715                 <xsl:value-of select="substring-after(@id, 'e')" />
716             </xsl:attribute>
717         </span>
718     </xsl:template>
719
720
721     <!--
722         ****************
723          TEKST WŁAŚCIWY
724         ****************
725     -->
726
727     <xsl:template match="text()">
728         <!-- <xsl:value-of select="." /> -->
729         <xsl:param name="mixed" />
730         <xsl:choose>
731             <xsl:when test="normalize-space(.) = ''" />
732             <xsl:when test="not($mixed)">
733                 <span x-node="out-of-flow-text" class="out-of-flow-text" x-editable="true">
734                         <xsl:value-of select="." />
735                                 </span>
736                         </xsl:when>
737             <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
738         </xsl:choose>
739     </xsl:template>
740
741     <xsl:template match="comment()">
742         <xsl:comment><xsl:value-of select="." /></xsl:comment>
743     </xsl:template>
744
745     <xsl:template match="*[name() != local-name()]">
746         <span>
747             <xsl:call-template name="standard-attributes" />
748             <xsl:apply-templates select="child::node()">
749                 <xsl:with-param name="mixed" select="true()" />
750             </xsl:apply-templates>
751         </span>
752     </xsl:template>
753         
754         <!-- 
755                 Earlier versions of html2wl introduced a BUG, that 'causes "out-of-flow-text" tag to appear.
756                 Instead of marking it as "unknown", just pass thru it
757         -->
758         <xsl:template match="out-of-flow-text">
759                 <xsl:param name="mixed" />
760                 <xsl:apply-templates select="child::node()">
761                 <xsl:with-param name="mixed" select="$mixed" />
762             </xsl:apply-templates>
763         </xsl:template> 
764
765     <xsl:template match="*">
766         <span class="unknown-tag" x-node="{name()}">
767             <xsl:apply-templates select="child::node()">
768                 <xsl:with-param name="mixed" select="true()" />
769             </xsl:apply-templates>        
770         </span>
771     </xsl:template>
772
773     <xsl:template name="context-menu">
774         <!-- <span class="default-menu context-menu"> -->
775         <!-- <button class="edit-button">Edytuj</button> -->
776             <!-- <span class="delete-button">Delete</span> -->
777         <!-- </span> -->
778         <!-- <span class="edit-menu context-menu">
779             <span class="accept-button">Accept</span>
780             <span class="reject-button">Close</span>
781         </span> -->
782     </xsl:template>
783
784     <xsl:template name="standard-attributes">
785         <xsl:param name="extra-class" />
786         <xsl:attribute name="class"><xsl:value-of select="local-name()" /><xsl:text>&#x0020;</xsl:text><xsl:value-of select="$extra-class" /></xsl:attribute>
787
788         <xsl:attribute name="x-node"><xsl:value-of select="local-name()" /></xsl:attribute>
789
790         <xsl:if test="local-name() != name()">
791             <xsl:attribute name="x-ns"><xsl:value-of select="namespace-uri()" /></xsl:attribute>
792         </xsl:if>
793
794         <xsl:for-each select="@*">
795             <xsl:variable name="id" select="generate-id()" />
796             <xsl:attribute name="x-attr-value-{$id}"><xsl:value-of select="."/></xsl:attribute>
797             <xsl:attribute name="x-attr-name-{$id}"><xsl:value-of select="local-name()"/></xsl:attribute>
798             <xsl:choose>
799                 <xsl:when test="namespace-uri()">
800                 <xsl:attribute name="x-attr-ns-{$id}"><xsl:value-of select="namespace-uri()"/></xsl:attribute>
801                                 </xsl:when>
802                                 <!-- if the element belongs to default namespace and attribut has no namespace -->
803                 <xsl:when test="not(namespace-uri(.))">
804                                 <xsl:attribute name="data-wlf-{local-name()}"><xsl:value-of select="."/></xsl:attribute>
805                                 </xsl:when>
806                         </xsl:choose>               
807         </xsl:for-each>
808     </xsl:template>
809     
810 </xsl:stylesheet>