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