programmation.xsl 18.2 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
                <xsl:apply-templates select="descendant::*[sp:question and ../name() != 'sp:question']/sp:question | descendant::*[sp:exercice]/sp:exercice"/>
Neveux Anais's avatar
Neveux Anais committed
31
32
33
            </body>
        </html>
    </xsl:template>
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    <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
51
52
53
    <xsl:template match="sp:sequence/cp:sequence">
        <section>
            <header>
54
55
                <h1><xsl:value-of select="./cp:sequenceM/sp:title"/></h1>
                <xsl:apply-templates select=".//cp:competence"/>
Neveux Anais's avatar
Neveux Anais committed
56
            </header>
57
58
59
60
61
62
63
64
65
66
67
68
            <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
69
70
71
        </section>
    </xsl:template>
    <xsl:template match="sp:session">
72
73
74
75
76
77
        <section>
            <header>
                <h1><xsl:value-of select="cp:session/cp:sessionM/sp:title"/></h1>
                <!-- gérer les sessionM -->
                
            </header>
78
            <xsl:apply-templates select="cp:session/*[name() != 'cp:sessionM']"/>
79
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
        </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
220
221
    
    
222
    <!-- ******** ACTIVITE TETM ********** -->
223
    <xsl:template match="sp:textActivity/cp:textActivity | sc:item/cp:textActivity | sp:section/cp:textActivity">
224
225
226
227
        <section>
            <header>
                <h1><xsl:value-of select="cp:activityM/sp:title"/></h1>
            </header>
228
           
229
            <xsl:apply-templates select="sp:body/cp:blocks/*[name() != 'sp:question' and name() != 'sp:exercice'] | sp:section/cp:textActivity"/>
230
231
232
233
234
235
        </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
236
237
    </xsl:template>
    
238
239
240
241
242
243
244
    <!-- 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
245
    </xsl:template>
246
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
    
    <!-- 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>

301
302
    <!-- Gestion methode -->
    <xsl:template match="sp:method">
303
304
305
306
        <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>
307
308
309
310
    </xsl:template>
    
    <!-- Gestion rappel -->
    <xsl:template match="sp:reminder">
311
312
313
314
        <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>
315
    </xsl:template>
316
317
318
    
    <!-- ******** FIN ACTIVITE TETM ********** -->
    
319
320
321
322
    
    <!-- ******** EXERCICE AVEC CORRIGE ******** -->
    
    <!-- Questionnement -->
323
324
    
    <xsl:template match="sp:question/cp:openQuestion | sp:exercice/cp:openQuestion">
325
326
327
328
        <section data-hdoc-type='exercise'>
            <header>
                <h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
            </header>
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
            <section>
                <header><h1/></header>
                <xsl:if test="sp:question/cp:flow/*">
                    <div data-hdoc-type='openQuestion'>
                        <xsl:apply-templates select="sp:question/cp:flow/sp:txt/cp:txt//sc:para"/>
                    </div>
                    <div data-hdoc-type='hint'>
                        <xsl:apply-templates select="sp:question/cp:flow/sp:profInstruction/cp:txt//sc:para"/>
                    </div>
                </xsl:if>
                <xsl:if test="../name() = 'sp:question' and 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>
        </section>
    </xsl:template>
    
    <xsl:template match="sc:item/cp:openQuestion">
        <xsl:param name="withoutExplanation"/>
        <section data-hdoc-type='exercise'>
            <header>
                <h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
            </header>
            <section>
                <header><h1/></header>
                <xsl:if test="sp:question/cp:flow/*">
                    <div data-hdoc-type='openQuestion'>
                        <xsl:apply-templates select="sp:question/cp:flow/sp:txt/cp:txt//sc:para"/>
                    </div>
                    <div data-hdoc-type='hint'>
                        <xsl:apply-templates select="sp:question/cp:flow/sp:profInstruction/cp:txt//sc:para"/>
                    </div>
                </xsl:if>
                <xsl:if test="$withoutExplanation = 'sp:question' and 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>
370
371
372
373
        </section>
    </xsl:template>
    
    <!-- QCM and QCU-->
374
375
376
    <!-- TODO Gérer les explications par choix -->
    <xsl:template match="sc:item/cp:qcm">
        <xsl:param name="withoutExplanation"/>
377
378
379
380
381
382
383
384
        <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"/>
385
            <xsl:if test="$withoutExplanation = 'sp:question' and sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
386
387
388
389
390
391
392
                <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>
    
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
    <xsl:template match="sp:question/cp:qcm | sp:exercice/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="../name() = 'sp:question' and 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:item/cp:qcu">
        <xsl:param name="withoutExplanation"/>
412
413
414
415
416
417
418
419
420
        <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>
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
            <xsl:if test="$withoutExplanation = 'sp:question' and 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">
        <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="../name() = 'sp:question' and sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
                <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]">
482
483
484
       <xsl:apply-templates select="document(@sc:refUri)/sc:item/*">
           <xsl:with-param name="withoutExplanation" select="name()"/>
       </xsl:apply-templates>
485
486
    </xsl:template>
    
487
    
488
489
490
    <xsl:template match="sp:question | sp:exercice">
        <xsl:apply-templates select="./*"/>
    </xsl:template>
Neveux Anais's avatar
Neveux Anais committed
491
</xsl:stylesheet>