conversion stub wl1->wl2
[redakcja.git] / redakcja / xslt / wl1to2.xslt
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:wl="http://wolnelektury.pl/functions"
4                 xmlns:dc="http://purl.org/dc/elements/1.1/"
5                 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
6     <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration="yes" version="2.0"/>
7
8     <xsl:template match="utwor">
9         <section xmlns:dc="http://purl.org/dc/elements/1.1/">
10             <xsl:apply-templates/>
11         </section>
12     </xsl:template>
13
14     <xsl:template match="rdf:RDF">
15         <xsl:apply-templates/>
16     </xsl:template>
17
18     <xsl:template match="rdf:Description">
19         <metadata>
20             <xsl:apply-templates mode="meta"/>
21         </metadata>
22     </xsl:template>
23
24     <xsl:template
25             match="dc:title|dc:identifier.url|dc:publisher|dc:rights|dc:rights.license|dc:format|dc:date"
26             mode="meta"/>
27
28     <!-- TODO language-dependent: description, audience, requires (subject.competence?) -->
29     <xsl:template
30             match="dc:creator.expert|dc:creator.scenario|dc:creator.textbook|dc:description|dc:subject.curriculum|dc:creator.methodologist|dc:subject.competence|dc:audience|dc:type|dc:requires|dc:language"
31             mode="meta">
32         <xsl:copy>
33             <xsl:apply-templates/>
34         </xsl:copy>
35     </xsl:template>
36
37     <xsl:template match="powiesc">
38         <xsl:apply-templates select="nazwa_utworu"/>
39         <xsl:apply-templates select="naglowek_rozdzial"/>
40     </xsl:template>
41
42     <xsl:template match="nazwa_utworu">
43         <header>
44             <xsl:apply-templates/>
45         </header>
46     </xsl:template>
47
48     <xsl:key name="k_rozdzial"
49            match="naglowek_podrozdzial"
50            use="generate-id(preceding-sibling::naglowek_rozdzial[1])"/>
51
52     <xsl:key name="k_last_header"
53              match="*[not(starts-with(name(),'naglowek_'))]"
54              use="generate-id(preceding-sibling::*[starts-with(name(),'naglowek_')][1])"/>
55
56     <xsl:template match="naglowek_rozdzial">
57         <section>
58             <xsl:if test="./text() = 'Pomysł na lekcję'">
59                 <metadata><dc:audience>teacher</dc:audience></metadata>
60             </xsl:if>
61             <header><xsl:apply-templates/></header>
62             <xsl:apply-templates select="key('k_last_header', generate-id())" mode="rozdzial"/>
63             <xsl:apply-templates select="key('k_rozdzial', generate-id())" mode="rozdzial"/>
64         </section>
65     </xsl:template>
66
67     <xsl:template match="naglowek_podrozdzial" mode="rozdzial">
68         <section>
69             <header><xsl:apply-templates/></header>
70             <xsl:apply-templates select="key('k_last_header', generate-id())" mode="rozdzial"/>
71         </section>
72     </xsl:template>
73
74     <xsl:template match="akap" mode="rozdzial">
75         <div class="p"><xsl:apply-templates mode="tekst"/></div>
76     </xsl:template>
77
78     <xsl:template match="akap" mode="opis">
79         <header><xsl:apply-templates mode="tekst"/></header>
80     </xsl:template>
81
82     <xsl:template match="lista" mode="rozdzial">
83         <div>
84             <xsl:attribute name="class">
85                 <xsl:choose>
86                     <xsl:when test="@typ = 'num'">list.enum</xsl:when>
87                     <xsl:when test="@typ = 'punkt'">list</xsl:when>
88                     <xsl:when test="@typ = 'slowniczek'">list.definitions</xsl:when>
89                     <xsl:when test="@typ = 'czytelnia'">list.bibliography</xsl:when>
90                 </xsl:choose>
91             </xsl:attribute>
92             <xsl:if test="@src != ''">
93                 <xsl:attribute name="src"><xsl:value-of select="@src"/></xsl:attribute>
94             </xsl:if>
95             <xsl:apply-templates mode="lista"/>
96         </div>
97     </xsl:template>
98
99     <xsl:template match="lista" mode="tekst">
100         <xsl:apply-templates select="." mode="rozdzial"/>
101     </xsl:template>
102
103     <xsl:template match="punkt" mode="lista">
104         <div class="item">
105             <xsl:apply-templates mode="tekst"/>
106         </div>
107     </xsl:template>
108
109     <xsl:template match="definiendum" mode="tekst">
110         <div class="defined">
111             <xsl:apply-templates mode="tekst"/>
112         </div>
113     </xsl:template>
114
115     <xsl:template match="aktywnosc" mode="rozdzial">
116         <section>
117             <xsl:apply-templates select="opis/akap[1]" mode="opis"/>
118             <xsl:apply-templates select="opis/*[position() > 1]" mode="rozdzial"/>
119             <xsl:apply-templates select="wskazowki" mode="rozdzial"/>
120             <div class="list.definitions">
121                 <xsl:apply-templates mode="aktywnosc"/>
122             </div>
123         </section>
124     </xsl:template>
125
126     <xsl:template match="czas" mode="aktywnosc">
127         <div class="item"><div class="defined">Czas</div><xsl:apply-templates mode="tekst"/></div>
128     </xsl:template>
129
130     <xsl:template match="forma" mode="aktywnosc">
131         <div class="item"><div class="defined">Metoda</div><xsl:apply-templates mode="tekst"/></div>
132     </xsl:template>
133
134     <xsl:template match="pomoce" mode="aktywnosc">
135         <div class="item"><div class="defined">Pomoce</div><xsl:apply-templates mode="tekst"/></div>
136     </xsl:template>
137
138     <xsl:template match="link" mode="tekst">
139         <div class="link">
140             <xsl:attribute name="href">
141                 <xsl:choose>
142                     <xsl:when test="@material">
143                         <xsl:value-of select="concat('file://', @material)"/>
144                     </xsl:when>
145                     <xsl:when test="@url">
146                         <xsl:value-of select="@url"/>
147                     </xsl:when>
148                 </xsl:choose>
149             </xsl:attribute>
150             <xsl:apply-templates mode="tekst"/>
151         </div>
152     </xsl:template>
153
154     <xsl:template match="wyroznienie" mode="tekst">
155         <div class="emp">
156             <xsl:apply-templates mode="tekst"/>
157         </div>
158     </xsl:template>
159
160     <xsl:template match="dlugi_cytat" mode="tekst">
161         <div class="cite">
162             <xsl:apply-templates mode="tekst"/>
163         </div>
164     </xsl:template>
165
166     <!-- exercises -->
167
168     <xsl:template match="cwiczenie" mode="rozdzial">
169
170     </xsl:template>
171
172 </xsl:stylesheet>