programmation.xsl 15 KB
Newer Older
Neveux Anais's avatar
Neveux Anais committed
1
<?xml version="1.0" encoding="UTF-8"?>
2
3
<xsl:stylesheet xmlns="http://www.utc.fr/ics/hdoc/xhtml"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
Neveux Anais's avatar
Neveux Anais committed
4
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
6
7
8
9
10
11
12
13
14
15
16
17
    exclude-result-prefixes="xs"
    version="2.0"
    xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"
    xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive"
    xmlns:cp="canope.fr:canoprof">
    <xsl:output method="xhtml"/>
    <xsl:strip-space elements="*" /> 
    <!-- Il faut uniformiser les sc:para -->
    <xsl:template match="sc:item">
        <xsl:apply-templates/>
    </xsl:template>
    <!--<xsl:template match="*"></xsl:template>-->
    <xsl:template match="cp:program">
Neveux Anais's avatar
Neveux Anais committed
18
        <xsl:processing-instruction name="oxygen">
19
         RNGSchema="../../schemas/xhtml/hdoc1-xhtml.rng" type="xml"</xsl:processing-instruction>
20
        <html>
Neveux Anais's avatar
Neveux Anais committed
21
            <head>
22
                <title><xsl:value-of select="cp:programM/sp:title"/></title>
Neveux Anais's avatar
Neveux Anais committed
23
24
                <meta charset="utf-8"/>
                <meta content="HdocConverter/Opale3.4" name="generator"/>
25
                <xsl:apply-templates select="cp:programM/child::*[name() != 'sp:abstract' and name()!= 'sp:title']"/>
Neveux Anais's avatar
Neveux Anais committed
26
27
            </head>
            <body>
28
29
                <xsl:apply-templates select="cp:programM/sp:abstract"/>
                <xsl:apply-templates select="child::*[name() != 'cp:programM']"/>
30
31
                <!-- TODO : apply-templates des exercices -->
                <xsl:apply-templates select="descendant::*[sp:question]/sp:question | descendant::*[sp:exercice]/sp:exercice"/>
Neveux Anais's avatar
Neveux Anais committed
32
33
34
            </body>
        </html>
    </xsl:template>
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    <xsl:template match="sp:class">
        <meta name="description" content="{.}" />
    </xsl:template>
    <xsl:template match="cp:programM/sp:period">
        <meta name="date" content="{.}" />
    </xsl:template>
    <xsl:template match="sp:abstract">
        <section data-hdoc-type="introduction">
            <header>
                <h1>Introduction</h1>
            </header>
            <!-- a introduction has only a bloc -->
            <div>
                <xsl:apply-templates select="./cp:txtDesc/*"/>
            </div>          
        </section>
    </xsl:template>
Neveux Anais's avatar
Neveux Anais committed
52
53
54
    <xsl:template match="sp:sequence/cp:sequence">
        <section>
            <header>
55
56
                <h1><xsl:value-of select="./cp:sequenceM/sp:title"/></h1>
                <xsl:apply-templates select=".//cp:competence"/>
Neveux Anais's avatar
Neveux Anais committed
57
            </header>
58
59
60
61
62
63
64
65
66
67
68
69
            <xsl:apply-templates select=".//sp:ojectives"/>
            <xsl:apply-templates select="child::*[name()!= 'cp:sequenceM']"/>
        </section>
    </xsl:template>
    <xsl:template match="sp:ojectives">
        <section>
            <header>
                <h1>Objectifs</h1>
            </header>
            <div>
                <xsl:apply-templates select="./cp:txtDesc/*"/>
            </div>
Neveux Anais's avatar
Neveux Anais committed
70
71
72
        </section>
    </xsl:template>
    <xsl:template match="sp:session">
73
74
75
76
77
78
        <section>
            <header>
                <h1><xsl:value-of select="cp:session/cp:sessionM/sp:title"/></h1>
                <!-- gérer les sessionM -->
                
            </header>
79
            <xsl:apply-templates select="cp:session/*[name() != 'cp:sessionM']"/>
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
        </section>
    </xsl:template>
    
    <xsl:template match="sp:profInstruction">
        <div><xsl:apply-templates select="cp:txt/sc:para"/></div>
    </xsl:template>
    
    <!-- ***** TEXT START ***** -->
    
    <!-- Simple text 
    <xsl:template match="cp:res/sp:txt">
        <xsl:apply-templates select="./op:txt/*" />
    </xsl:template>-->
    
    <!-- Paragraph -->
    <xsl:template match="sc:para"> 
        <p>
            <xsl:apply-templates select="./* | ./text()" />
        </p>
    </xsl:template>
    
    <!-- ***** PARAGRAPH ITEMS START ***** -->
    
    <!-- citation -->
    <xsl:template match="sc:para/sc:inlineStyle[@role='quote']" priority="2">
        <q>
            <xsl:value-of select="." />
        </q>
    </xsl:template>
    <!-- important -->
    <xsl:template match="sc:para/sc:inlineStyle[@role='emphasis']" priority="2">
        <em>
            <xsl:value-of select="." />
        </em>
    </xsl:template>
    <!-- foreign term -->
    <xsl:template match="sc:para/sc:inlineStyle[@role='specific']" priority="2">
        <i>
            <xsl:value-of select="." />
        </i>
    </xsl:template>
    <!-- syntax -->
    <xsl:template match="sc:para/sc:inlineStyle[@role='code']" priority="2">
        <span data-hdoc-type="syntax">
            <xsl:value-of select="." />
        </span>
    </xsl:template>
    
    <xsl:template match="sc:para/sc:uLink" priority="2">
        <xsl:value-of select="." />
    </xsl:template>
    <!-- exponent -->
    <xsl:template match="sc:para/sc:textLeaf[@role='exp']" priority="2">
        <sup>
            <xsl:value-of select="." />
        </sup>
    </xsl:template>
    <!-- subscript -->
    <xsl:template match="sc:para/sc:textLeaf[@role='ind']" priority="2">
        <sub>
            <xsl:value-of select="." />
        </sub>
    </xsl:template>
    <!-- latex -->
    <xsl:template match="sc:para/sc:textLeaf[@role='mathtex']" priority="2">
        <span data-hdoc-type="latex">
            <xsl:value-of select="." />
        </span>
    </xsl:template>
    <!-- default behaviour for other balises -->
    <xsl:template match="sc:para/sc:inlineStyle|sc:para/sc:textLeaf" priority="1">
        <xsl:value-of select="." />
    </xsl:template>
    
    <xsl:template match="sc:para/sc:phrase[@role='url']">
        <xsl:apply-templates select="cp:link"/>
    </xsl:template>
    
    <xsl:template match="cp:link">
        <a href="{sp:url/text()}"><xsl:value-of select="sp:title/text()"></xsl:value-of></a>
    </xsl:template>
    
    <!-- ***** PARAGRAPH ITEMS END ***** -->
    
    <!-- List-->
    <xsl:template match="sc:itemizedList">
        <ul>
            <xsl:apply-templates select="./sc:listItem" />
        </ul>
    </xsl:template>
    
    <!-- Ordered list -->
    <xsl:template match="sc:orderedList">
        <ol>
            <xsl:apply-templates select="./sc:listItem" />
        </ol>
    </xsl:template>
    
    <!-- ***** LIST ITEMS START ***** -->
    
    <!-- List item -->
    <xsl:template match="sc:listItem">
        <li>
            <xsl:apply-templates select="./*" />
        </li>
    </xsl:template>
    
    <!-- ***** LIST ITEMS END ***** -->
    
    <!-- Table -->
    <xsl:template match="sc:table">
        <table>
            <xsl:apply-templates select="./*" />
        </table>
    </xsl:template>
    
    <!-- ***** TABLE ITEMS START ***** -->
    
    <!-- caption -->
    <xsl:template match="sc:table/sc:caption">
        <caption>
            <xsl:value-of select="."></xsl:value-of>
        </caption>
    </xsl:template>
    <!-- table row -->
    <xsl:template match="sc:table/sc:row">
        <tr>
            <xsl:apply-templates select="./*" />
        </tr>
    </xsl:template>
    <!-- table cell -->
    <xsl:template match="sc:table/sc:row/sc:cell">
        <td>
            <xsl:apply-templates select="./*" />
        </td>
    </xsl:template>
    
    <!-- ***** TABLE ITEMS END ***** -->
    
    <!-- ***** TEXT END ***** -->
    
Neveux Anais's avatar
Neveux Anais committed
221
222
    
    
223
    <!-- ******** ACTIVITE TETM ********** -->
224
    <xsl:template match="sp:textActivity/cp:textActivity | sc:item/cp:textActivity | sp:section/cp:textActivity">
225
226
227
228
        <section>
            <header>
                <h1><xsl:value-of select="cp:activityM/sp:title"/></h1>
            </header>
229
           
230
            <xsl:apply-templates select="sp:body/cp:blocks/*[name() != 'sp:question' and name() != 'sp:exercice'] | sp:section/cp:textActivity"/>
231
232
233
234
235
236
        </section>
    </xsl:template>
    
    <!-- Gestion transclusion d'activite -->
    <xsl:template match="sp:textActivity[@sc:refUri]">
        <xsl:apply-templates select="document(@sc:refUri)"/>
Neveux Anais's avatar
Neveux Anais committed
237
238
    </xsl:template>
    
239
240
241
242
243
244
245
    <!-- Gestion information -->
    <xsl:template match="sp:info">
        <div>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <!-- TODO gerer plusieurs types de paragraphe -->
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
Neveux Anais's avatar
Neveux Anais committed
246
    </xsl:template>
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
    
    <!-- Gestion warning -->
    <xsl:template match="sp:warning">
        <div data-hdoc-type='warning'>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <!-- TODO gerer plusieurs types de paragraphe -->
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
    </xsl:template>
    
    <!-- Gestion complement -->
    <xsl:template match="sp:extra">
        <div data-hdoc-type='complement'>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <!-- TODO gerer plusieurs types de paragraphe -->
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
    </xsl:template>
    
    <!-- Gestion conseil -->
    <xsl:template match="sp:advice">
        <div data-hdoc-type='advice'>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <!-- TODO gerer plusieurs types de paragraphe -->
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
    </xsl:template>
    
    <!-- Gestion definition -->
    <xsl:template match="sp:definition">
        <div data-hdoc-type='definition'>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <!-- TODO gerer plusieurs types de paragraphe -->
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
    </xsl:template>
    
    <!-- Gestion exemple -->
    <xsl:template match="sp:example">
        <div data-hdoc-type='example'>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <!-- TODO gerer plusieurs types de paragraphe -->
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
    </xsl:template>
    
    <!-- Gestion hypothese -->
    <xsl:template match="sp:hypothesis">
        <div data-hdoc-type='remark'>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <!-- TODO gerer plusieurs types de paragraphe -->
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
    </xsl:template>

302
303
    <!-- Gestion methode -->
    <xsl:template match="sp:method">
304
305
306
307
        <div data-hdoc-type='method'>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
308
309
310
311
    </xsl:template>
    
    <!-- Gestion rappel -->
    <xsl:template match="sp:reminder">
312
313
314
315
        <div data-hdoc-type='remind'>
            <h6><xsl:value-of select="cp:block/cp:blockM/sp:title"/></h6>
            <xsl:apply-templates select="cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
        </div>
316
    </xsl:template>
317
318
319
    
    <!-- ******** FIN ACTIVITE TETM ********** -->
    
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
    
    <!-- ******** EXERCICE AVEC CORRIGE ******** -->
    
    <!-- Questionnement -->
    <!-- TODO gerer multiple texte, remarque prof, ect... -->
    <xsl:template match="sp:question/cp:openQuestion">
        <section data-hdoc-type='exercise'>
            <header>
                <h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
            </header>
            <!-- TODO work with description -->
            <xsl:if test="sp:question/cp:flow/*">
                <div data-hdoc-type='question'>
                    <xsl:apply-templates select="sp:question/cp:flow/sp:txt/cp:txt/sc:para"/>
                </div>
            </xsl:if>
            <xsl:if test="sp:solution">
                <div data-hdoc-type='solution'>
                    <xsl:apply-templates select="sp:solution/cp:flow/sp:txt/cp:txt/sc:para"/>
                </div>
            </xsl:if>
            
        </section>
    </xsl:template>
    
    <!-- QCM and QCU-->
    <xsl:template match="sp:question/cp:qcm | sp:exercice/cp:qcm | sc:item/cp:qcm">
        <section>
            <header>
                <h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
            </header>
            <div data-hdoc-type = 'question'>
                <xsl:apply-templates select='sc:question/cp:block'/>
            </div>
            <xsl:apply-templates select="sc:choices/sc:choice"/>
            <xsl:if test="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
                <div data-hdoc-type='explanation'>
                    <xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
                </div>            
            </xsl:if>
        </section>
    </xsl:template>
    
    <xsl:template match="sp:question/cp:qcu | sp:exercice/cp:qcu | sc:item/cp:qcu">
        <section>
            <header>
                <h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
            </header>
            <div data-hdoc-type='singlechoicequestion'>
                <xsl:apply-templates select="sc:question/cp:block"/>
            </div>
            <xsl:apply-templates select="sc:choices//sc:choice"/>
            <div data-hdoc-type='solution'><p><xsl:value-of select="sc:solution/@choice"/></p></div>
            <xsl:if test="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
                <div data-hdoc-type='explanation'>
                    <xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
                </div>            
            </xsl:if>
    
        </section>
    </xsl:template>
    
    <xsl:template match="sc:choice">
        <div data-hdoc-type='choice'>
            <xsl:apply-templates select="sc:choiceLabel/cp:txt/sc:para"/>
        </div>
        <xsl:if test="sc:choiceExplanation">
            <div data-hdoc-type='explanation-choice-correct'>
                <xsl:apply-templates select="sc:choiceExplanation/cp:txt/sc:para"/>
            </div>    
        </xsl:if>
        
    </xsl:template>
    
    <xsl:template match="sc:choice[@solution]">
        <xsl:choose>
            <xsl:when test="@solution = 'checked'">
                <div data-hdoc-type='choice-correct'>
                    <xsl:apply-templates select="sc:choiceLabel/cp:txt/sc:para"/>
                </div>
            </xsl:when>
            <xsl:otherwise>
                <div data-hdoc-type='choice-incorrect'>
                    <xsl:apply-templates select="sc:choiceLabel/cp:txt/sc:para"/>
                </div>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="sc:choiceExplanation">
            <div data-hdoc-type='explanation-choice-correct'>
                <xsl:apply-templates select="sc:choiceExplanation/cp:txt/sc:para"/>
            </div>    
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="sp:question[@sc:refUri] | sp:exercice[@sc:refUri]">
        <xsl:apply-templates select="document(@sc:refUri)"/>
    </xsl:template>
    
    <xsl:template match="sp:question | sp:exercice">
        <xsl:apply-templates select="./*"/>
    </xsl:template>
Neveux Anais's avatar
Neveux Anais committed
421
</xsl:stylesheet>