transform exercises order and true-or-false to WL1
[redakcja.git] / redakcja / xslt / wl2to1.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 <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" version="2.0" />
6
7 <xsl:template match="section">
8     <xsl:choose>
9         <xsl:when test="not(ancestor::*)">
10         <utwor xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wl="http://wolnelektury.pl/functions">
11         <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
12         <rdf:Description>
13             <xsl:attribute name="rdf:about">
14                 <xsl:text>http://redakcja.edukacjamedialna.edu.pl/documents/book/</xsl:text>
15                 <xsl:value-of select="@redslug" />
16                 <xsl:text>/</xsl:text>
17             </xsl:attribute>
18             <dc:title xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/"><xsl:apply-templates select="header/text()" /></dc:title>
19             <dc:identifier.url xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">
20                 <xsl:text>http://edukacjamedialna.edu.pl/lekcje/</xsl:text>
21                 <xsl:value-of select="@wlslug" />
22                 <xsl:text>/</xsl:text>
23             </dc:identifier.url>
24
25             <!--dc:creator.expert xml:lang="pl" ></dc:creator.expert>
26             <dc:creator.methodologist xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/"></dc:creator.methodologist>
27             <dc:creator.scenario xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/"></dc:creator.scenario>
28             <dc:creator.textbook xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/"></dc:creator.textbook-->
29
30             <xsl:apply-templates select="metadata" mode="meta" />
31
32             <dc:publisher xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">Fundacja Nowoczesna Polska</dc:publisher>
33             <dc:rights xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">Creative Commons Uznanie autorstwa - Na tych samych warunkach 3.0</dc:rights>
34             <dc:rights.license xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">http://creativecommons.org/licenses/by-sa/3.0/</dc:rights.license>
35             <dc:format xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">xml</dc:format>
36             <!--dc:type xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">added-var</dc:type-->
37             <dc:date xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">2015-01-12</dc:date>
38             <!--dc:audience xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/"><!- -liceum - -><xsl:value-of select="//dc:audience/text()" /></dc:audience-->
39             <dc:language xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">pol</dc:language>
40         </rdf:Description>
41         </rdf:RDF>
42         <powiesc>
43             <xsl:apply-templates />
44         </powiesc>
45         </utwor>
46         </xsl:when>
47         <xsl:when test="count(ancestor::*) = 3">
48             <aktywnosc>
49                 <opis><xsl:apply-templates select="header" /><xsl:apply-templates select="div" mode="opis" /></opis>
50                 <xsl:apply-templates select="div" mode="aktywnosc" />
51                 <xsl:apply-templates select="section" mode="error" />
52             </aktywnosc>
53         </xsl:when>
54         <xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
55     </xsl:choose>
56 </xsl:template>
57
58 <!-- TODO language-dependent: description, audience, requires (subject.competence?) -->
59 <xsl:template 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" mode="meta">
60     <xsl:copy><xsl:apply-templates /></xsl:copy>
61 </xsl:template>
62
63 <xsl:template match="metadata"></xsl:template>
64 <xsl:template match="aside"></xsl:template>
65
66
67 <xsl:template match="header">
68     <xsl:choose>
69         <xsl:when test="count(ancestor::*) = 1">
70             <nazwa_utworu><xsl:apply-templates /></nazwa_utworu>
71         </xsl:when>
72         <xsl:when test="count(ancestor::*) = 2">
73             <naglowek_rozdzial><xsl:apply-templates /></naglowek_rozdzial>
74         </xsl:when>
75         <xsl:when test="count(ancestor::*) = 3">
76             <naglowek_podrozdzial><xsl:apply-templates /></naglowek_podrozdzial>
77         </xsl:when>
78         <xsl:when test="count(ancestor::*) = 4">
79             <akap><xsl:apply-templates /></akap>
80         </xsl:when>
81     </xsl:choose>
82 </xsl:template>
83
84
85 <xsl:template match="div">
86     <xsl:choose>
87         <xsl:when test="@class = 'p'">
88             <akap><xsl:apply-templates /></akap>
89         </xsl:when>
90         <xsl:when test="@class = 'list'">
91             <lista typ="punkt"><xsl:apply-templates /></lista>
92         </xsl:when>
93         <xsl:when test="@class = 'list.itemized'">
94             <lista typ="punkt"><xsl:apply-templates /></lista>
95         </xsl:when>
96         <xsl:when test="@class = 'list.enum'">
97             <lista typ="num"><xsl:apply-templates /></lista>
98         </xsl:when>
99         <xsl:when test="@class = 'list.definitions'">
100             <xsl:choose>
101                 <xsl:when test="@src = ''">
102                     <lista typ="slowniczek"><xsl:apply-templates /></lista>
103                 </xsl:when>
104                 <xsl:otherwise>
105                     <lista typ="slowniczek" src="{@src}"><xsl:apply-templates /></lista>
106                 </xsl:otherwise>
107             </xsl:choose>
108         </xsl:when>
109         <xsl:when test="@class = 'list.bibliography'">
110             <lista typ="czytelnia"><xsl:apply-templates /></lista>
111         </xsl:when>
112         <xsl:when test="@class = 'item'">
113             <punkt><xsl:apply-templates /></punkt>
114         </xsl:when>
115         <xsl:when test="@class = 'defined'">
116             <xsl:choose>
117                 <xsl:when test="count(ancestor::*) = 4 ">
118                     <definiendum><xsl:apply-templates /></definiendum>
119                 </xsl:when>
120                 <xsl:otherwise>
121                 </xsl:otherwise>
122             </xsl:choose>
123         </xsl:when>
124         <xsl:when test="@class = 'exercise.order'">
125             <cwiczenie typ="uporzadkuj">
126                 <xsl:for-each select="div">
127                     <xsl:choose>
128                         <xsl:when test="@class = 'p'">
129                             <opis><akap><xsl:value-of select="."/></akap></opis>
130                         </xsl:when>
131                         <xsl:when test="@class = 'list.orderable'">
132                             <lista typ="punkt">
133                                 <xsl:apply-templates select="div" mode="exercise.order.list"/>
134                             </lista>
135                         </xsl:when>
136                     </xsl:choose>
137                 </xsl:for-each>
138             </cwiczenie>
139         </xsl:when>
140         <xsl:when test="@class = 'exercise.choice.true-or-false'">
141             <cwiczenie typ="prawdafalsz">
142                 <xsl:for-each select="div">
143                     <xsl:choose>
144                         <xsl:when test="@class = 'p'">
145                             <opis><akap><xsl:value-of select="."/></akap></opis>
146                         </xsl:when>
147                         <xsl:when test="@class = 'list'">
148                             <lista typ="punkt">
149                                 <xsl:apply-templates select="div" mode="exercise.true-or-false"/>
150                             </lista>
151                         </xsl:when>
152                     </xsl:choose>
153                 </xsl:for-each>
154             </cwiczenie>
155         </xsl:when>
156         <xsl:otherwise>
157             <NIEZNANY_DIV><xsl:value-of select="@class" /></NIEZNANY_DIV>
158         </xsl:otherwise>
159     </xsl:choose>
160 </xsl:template>
161
162 <xsl:template match="div" mode="opis">
163     <xsl:choose>
164         <xsl:when test="@class = 'p'">
165             <akap><xsl:apply-templates /></akap>
166         </xsl:when>
167         <xsl:when test="@class = 'list'">
168             <lista typ="punkt"><xsl:apply-templates /></lista>
169         </xsl:when>
170         <xsl:when test="@class = 'list.itemized'">
171             <lista typ="punkt"><xsl:apply-templates /></lista>
172         </xsl:when>
173         <xsl:when test="@class = 'item'">
174             <punkt><xsl:apply-templates /></punkt>
175         </xsl:when>
176     </xsl:choose>
177 </xsl:template>
178
179 <xsl:template match="div" mode="aktywnosc">
180     <xsl:choose>
181         <xsl:when test="@class = 'list.definitions'">
182             <xsl:apply-templates mode="defs" />
183         </xsl:when>
184     </xsl:choose>
185 </xsl:template>
186
187
188 <xsl:template match="div" mode="defs">
189     <xsl:choose>
190         <xsl:when test="div/text() = 'Czas'"><czas><xsl:apply-templates /></czas></xsl:when>
191         <xsl:when test="div/text() = 'Metoda'"><forma><xsl:apply-templates /></forma></xsl:when>
192         <xsl:when test="div/text() = 'Pomoce'"><pomoce><xsl:apply-templates /></pomoce></xsl:when>
193     </xsl:choose>
194 </xsl:template>
195
196 <xsl:template match="span">
197     <xsl:choose>
198         <xsl:when test="@class = 'link'">
199             <link>
200                 <xsl:choose>
201                     <xsl:when test="starts-with(@href, 'file://')">
202                         <xsl:attribute name="material">
203                             <xsl:value-of select="wl:rmext(substring(@href, 8))" />
204                         </xsl:attribute>
205                     </xsl:when>
206                     <xsl:when test="starts-with(@href, 'http')">
207                         <xsl:attribute name="url">
208                             <xsl:value-of select="@href" />
209                         </xsl:attribute>
210                     </xsl:when>
211                     <xsl:otherwise>
212                         <xsl:attribute name="url">
213                             <xsl:value-of select="text()" />
214                         </xsl:attribute>
215                     </xsl:otherwise>
216                 </xsl:choose>
217                 <xsl:apply-templates />
218             </link>
219         </xsl:when>
220         <xsl:when test="@class = 'emp'">
221             <wyroznienie><xsl:apply-templates /></wyroznienie>
222         </xsl:when>
223         <xsl:when test="@class = 'cite'">
224             <dlugi_cytat><xsl:apply-templates /></dlugi_cytat>
225         </xsl:when>
226         <xsl:otherwise>
227             <NIEZNANY_SPAN><xsl:value-of select="@class" /></NIEZNANY_SPAN>
228         </xsl:otherwise>
229     </xsl:choose>
230 </xsl:template>
231
232 <xsl:template match="div" mode="exercise.order.list">
233     <punkt rozw="{@answer}"><xsl:value-of select="."/></punkt>
234 </xsl:template>
235
236 <xsl:template match="div" mode="exercise.true-or-false">
237     <xsl:element name="punkt">
238         <xsl:choose>
239             <xsl:when test="@answer = 'true'">
240                 <xsl:attribute name="rozw">prawda</xsl:attribute>
241             </xsl:when>
242             <xsl:when test="@answer = 'false'">
243                 <xsl:attribute name="rozw">falsz</xsl:attribute>
244             </xsl:when>
245         </xsl:choose>
246         <xsl:value-of select="."/>
247     </xsl:element>
248 </xsl:template>
249
250 <xsl:template match="section" mode="error">
251     NIEZNANA_SEKCJA
252 </xsl:template>
253
254 </xsl:stylesheet>