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