"publish" button
[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             <lista typ="slowniczek"><xsl:apply-templates /></lista>
104         </xsl:when>
105         <xsl:when test="@class = 'list.bibliography'">
106             <lista typ="czytelnia"><xsl:apply-templates /></lista>
107         </xsl:when>
108         <xsl:when test="@class = 'item'">
109             <punkt><xsl:apply-templates /></punkt>
110         </xsl:when>
111         <xsl:when test="@class = 'defined'">
112             <xsl:choose>
113                 <xsl:when test="count(ancestor::*) = 4 ">
114                     <definiendum><xsl:apply-templates /></definiendum>
115                 </xsl:when>
116                 <xsl:otherwise>
117                 </xsl:otherwise>
118             </xsl:choose>
119         </xsl:when>
120         <xsl:otherwise>
121             <NIEZNANY_DIV><xsl:value-of select="@class" /></NIEZNANY_DIV>
122         </xsl:otherwise>
123     </xsl:choose>
124 </xsl:template>
125
126 <xsl:template match="div" mode="opis">
127     <xsl:choose>
128         <xsl:when test="@class = 'p'">
129             <akap><xsl:apply-templates /></akap>
130         </xsl:when>
131         <xsl:when test="@class = 'list'">
132             <lista typ="punkt"><xsl:apply-templates /></lista>
133         </xsl:when>
134         <xsl:when test="@class = 'list.itemized'">
135             <lista typ="punkt"><xsl:apply-templates /></lista>
136         </xsl:when>
137         <xsl:when test="@class = 'item'">
138             <punkt><xsl:apply-templates /></punkt>
139         </xsl:when>
140     </xsl:choose>
141 </xsl:template>
142
143 <xsl:template match="div" mode="aktywnosc">
144     <xsl:choose>
145         <xsl:when test="@class = 'list.definitions'">
146             <xsl:apply-templates mode="defs" />
147         </xsl:when>
148     </xsl:choose>
149 </xsl:template>
150
151
152 <xsl:template match="div" mode="defs">
153     <xsl:choose>
154         <xsl:when test="div/text() = 'Czas'"><czas><xsl:apply-templates /></czas></xsl:when>
155         <xsl:when test="div/text() = 'Metoda'"><forma><xsl:apply-templates /></forma></xsl:when>
156         <xsl:when test="div/text() = 'Pomoce'"><pomoce><xsl:apply-templates /></pomoce></xsl:when>
157     </xsl:choose>
158 </xsl:template>
159
160 <xsl:template match="span">
161     <xsl:choose>
162         <xsl:when test="@class = 'link'">
163             <link>
164                 <xsl:choose>
165                     <xsl:when test="starts-with(@href, 'file://')">
166                         <xsl:attribute name="material">
167                             <xsl:value-of select="wl:rmext(substring(@href, 8))" />
168                         </xsl:attribute>
169                     </xsl:when>
170                     <xsl:when test="starts-with(@href, 'http')">
171                                     <xsl:attribute name="url">
172                                             <xsl:value-of select="@href" />
173                                     </xsl:attribute>
174                     </xsl:when>
175                     <xsl:otherwise>
176                                     <xsl:attribute name="url">
177                                             <xsl:value-of select="text()" />
178                                     </xsl:attribute>
179                     </xsl:otherwise>
180             </xsl:choose>
181                                 <xsl:apply-templates />
182             </link>
183         </xsl:when>
184         <xsl:when test="@class = 'emp'">
185             <wyroznienie><xsl:apply-templates /></wyroznienie>
186     </xsl:when>
187     <xsl:when test="@class='cite'">
188             <dlugi_cytat><xsl:apply-templates /></dlugi_cytat>
189     </xsl:when>
190         <xsl:otherwise>
191             <NIEZNANY_SPAN><xsl:value-of select="@class" /></NIEZNANY_SPAN>
192         </xsl:otherwise>
193     </xsl:choose>
194 </xsl:template>
195
196
197 <xsl:template match="section" mode="error">
198     NIEZNANA_SEKCJA
199 </xsl:template>
200
201 </xsl:stylesheet>