pass src attribute for słowniczek
[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:when test='header/text() = "Zadanie dla ucznia..."'>
55
56 </xsl:when>
57     <xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
58     </xsl:choose>
59 </xsl:template>
60
61 <!-- TODO language-dependent: description, audience, requires (subject.competence?) -->
62 <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">
63     <xsl:copy><xsl:apply-templates /></xsl:copy>
64 </xsl:template>
65
66 <xsl:template match="metadata"></xsl:template>
67 <xsl:template match="aside"></xsl:template>
68
69
70 <xsl:template match="header">
71     <xsl:choose>
72         <xsl:when test="count(ancestor::*) = 1">
73             <nazwa_utworu><xsl:apply-templates /></nazwa_utworu>
74         </xsl:when>
75         <xsl:when test="count(ancestor::*) = 2">
76             <naglowek_rozdzial><xsl:apply-templates /></naglowek_rozdzial>
77         </xsl:when>
78         <xsl:when test="count(ancestor::*) = 3">
79             <naglowek_podrozdzial><xsl:apply-templates /></naglowek_podrozdzial>
80         </xsl:when>
81         <xsl:when test="count(ancestor::*) = 4">
82             <akap><xsl:apply-templates /></akap>
83         </xsl:when>
84     </xsl:choose>
85 </xsl:template>
86
87
88 <xsl:template match="div">
89     <xsl:choose>
90         <xsl:when test="@class = 'p'">
91             <akap><xsl:apply-templates /></akap>
92         </xsl:when>
93         <xsl:when test="@class = 'list'">
94             <lista typ="punkt"><xsl:apply-templates /></lista>
95         </xsl:when>
96         <xsl:when test="@class = 'list.itemized'">
97             <lista typ="punkt"><xsl:apply-templates /></lista>
98         </xsl:when>
99         <xsl:when test="@class = 'list.enum'">
100             <lista typ="num"><xsl:apply-templates /></lista>
101         </xsl:when>
102         <xsl:when test="@class = 'list.definitions'">
103             <xsl:choose>
104                 <xsl:when test="@src = ''">
105                     <lista typ="slowniczek"><xsl:apply-templates /></lista>
106                 </xsl:when>
107                 <xsl:otherwise>
108                     <lista typ="slowniczek" src="{@src}"><xsl:apply-templates /></lista>
109                 </xsl:otherwise>
110             </xsl:choose>
111         </xsl:when>
112         <xsl:when test="@class = 'list.bibliography'">
113             <lista typ="czytelnia"><xsl:apply-templates /></lista>
114         </xsl:when>
115         <xsl:when test="@class = 'item'">
116             <punkt><xsl:apply-templates /></punkt>
117         </xsl:when>
118         <xsl:when test="@class = 'defined'">
119             <xsl:choose>
120                 <xsl:when test="count(ancestor::*) = 4 ">
121                     <definiendum><xsl:apply-templates /></definiendum>
122                 </xsl:when>
123                 <xsl:otherwise>
124                 </xsl:otherwise>
125             </xsl:choose>
126         </xsl:when>
127         <xsl:otherwise>
128             <NIEZNANY_DIV><xsl:value-of select="@class" /></NIEZNANY_DIV>
129         </xsl:otherwise>
130     </xsl:choose>
131 </xsl:template>
132
133 <xsl:template match="div" mode="opis">
134     <xsl:choose>
135         <xsl:when test="@class = 'p'">
136             <akap><xsl:apply-templates /></akap>
137         </xsl:when>
138         <xsl:when test="@class = 'list'">
139             <lista typ="punkt"><xsl:apply-templates /></lista>
140         </xsl:when>
141         <xsl:when test="@class = 'list.itemized'">
142             <lista typ="punkt"><xsl:apply-templates /></lista>
143         </xsl:when>
144         <xsl:when test="@class = 'item'">
145             <punkt><xsl:apply-templates /></punkt>
146         </xsl:when>
147     </xsl:choose>
148 </xsl:template>
149
150 <xsl:template match="div" mode="aktywnosc">
151     <xsl:choose>
152         <xsl:when test="@class = 'list.definitions'">
153             <xsl:apply-templates mode="defs" />
154         </xsl:when>
155     </xsl:choose>
156 </xsl:template>
157
158
159 <xsl:template match="div" mode="defs">
160     <xsl:choose>
161         <xsl:when test="div/text() = 'Czas'"><czas><xsl:apply-templates /></czas></xsl:when>
162         <xsl:when test="div/text() = 'Metoda'"><forma><xsl:apply-templates /></forma></xsl:when>
163         <xsl:when test="div/text() = 'Pomoce'"><pomoce><xsl:apply-templates /></pomoce></xsl:when>
164     </xsl:choose>
165 </xsl:template>
166
167 <xsl:template match="span">
168     <xsl:choose>
169         <xsl:when test="@class = 'link'">
170             <link>
171                 <xsl:choose>
172                     <xsl:when test="starts-with(@href, 'file://')">
173                         <xsl:attribute name="material">
174                             <xsl:value-of select="wl:rmext(substring(@href, 8))" />
175                         </xsl:attribute>
176                     </xsl:when>
177                     <xsl:when test="starts-with(@href, 'http')">
178                                     <xsl:attribute name="url">
179                                             <xsl:value-of select="@href" />
180                                     </xsl:attribute>
181                     </xsl:when>
182                     <xsl:otherwise>
183                                     <xsl:attribute name="url">
184                                             <xsl:value-of select="text()" />
185                                     </xsl:attribute>
186                     </xsl:otherwise>
187             </xsl:choose>
188                                 <xsl:apply-templates />
189             </link>
190         </xsl:when>
191         <xsl:when test="@class = 'emp'">
192             <wyroznienie><xsl:apply-templates /></wyroznienie>
193     </xsl:when>
194     <xsl:when test="@class='cite'">
195             <dlugi_cytat><xsl:apply-templates /></dlugi_cytat>
196     </xsl:when>
197         <xsl:otherwise>
198             <NIEZNANY_SPAN><xsl:value-of select="@class" /></NIEZNANY_SPAN>
199         </xsl:otherwise>
200     </xsl:choose>
201 </xsl:template>
202
203
204 <xsl:template match="section" mode="error">
205     NIEZNANA_SEKCJA
206 </xsl:template>
207
208 </xsl:stylesheet>