chapitre.xsl 7.95 KB
Newer Older
1
2
3
4
5
6
7
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    version="2.0">
8

9
    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
10

11
    <xsl:template match="/html" priority="10">
cliclac's avatar
cliclac committed
12
13
14
15
16
17
18
19
20
21
22
23
24
        <xsl:result-document method="xml" href="../../../retour/oebps/chapitres/titlepage.xhtml">
            <html xml:lang="fr" lang="fr" xmlns:epub="http://www.idpf.org/2007/ops">
                <head>
                    <title><xsl:value-of select="head/title"/></title>
                    <meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/>
                    <link href="../styles/stylesheet.css" type="text/css" rel="stylesheet"/>
                </head>
                <body>
                    <div class="titlePage"><xsl:value-of select="head/title"/></div>
                    <div class="subTitlePage"><xsl:value-of select="head/meta[@name='author']/@content"/></div>
                </body>
            </html>
        </xsl:result-document>
cliclac's avatar
cliclac committed
25
        <xsl:for-each select="/html/body/section">
26
27
            <xsl:variable name="path">../../../retour/oebps/chapitres/chapitre<xsl:number level="multiple" count="section" format="1"/>.xhtml</xsl:variable>
            <xsl:result-document method="xml" href="{$path}">
cliclac's avatar
cliclac committed
28
                <html xml:lang="fr" lang="fr" xmlns:epub="http://www.idpf.org/2007/ops">
29
30
                    <head>
                        <title><xsl:value-of select="header/h1"/></title>
cliclac's avatar
cliclac committed
31
32
                        <meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/>
                        <link href="../styles/stylesheet.css" type="text/css" rel="stylesheet"/>
33
34
35
36
37
38
39
40
41
                    </head>
                    <body>
                        <h1><xsl:value-of select="header/h1"/></h1>
                        <xsl:apply-templates select="div|section"/>
                    </body>
                </html>
            </xsl:result-document>
        </xsl:for-each>
    </xsl:template>
42

cliclac's avatar
cliclac committed
43
44
45
    <xsl:template match="//section[count(ancestor::section) = 1 and position() &gt; 1]" priority="9">
        <xsl:variable name="path">../../../retour/oebps/chapitres/chapitre<xsl:number level="multiple" count="section" format="1_1"/>.xhtml</xsl:variable>
        <xsl:result-document method="xml" href="{$path}">
cliclac's avatar
cliclac committed
46
            <html xml:lang="fr" lang="fr" xmlns:epub="http://www.idpf.org/2007/ops">
cliclac's avatar
cliclac committed
47
48
49
50
51
52
53
54
55
56
57
58
                <head>
                    <title><xsl:value-of select="header/h1"/></title>
                    <meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/>
                    <link href="../styles/stylesheet.css" type="text/css" rel="stylesheet"/>
                </head>
                <body>
                    <h2><xsl:value-of select="header/h1"/></h2>
                    <xsl:apply-templates select="div|section"/>
                </body>
            </html>
        </xsl:result-document>
    </xsl:template>
cliclac's avatar
cliclac committed
59
    
60
61
    <xsl:template match="section" priority="3">
        <xsl:element name="h{count(ancestor::section)+1}">
cliclac's avatar
cliclac committed
62
63
64
            <xsl:if test="section[@data-hdoc-type='exercise']">
                Exercice : 
            </xsl:if>
65
66
            <xsl:value-of select="header/h1"/>
        </xsl:element>
67
        <xsl:apply-templates select="div|section"/>
68
    </xsl:template>
69

cliclac's avatar
cliclac committed
70
71
    <xsl:template match="h6" priority="3"/>
    
Asus-PC's avatar
css  
Asus-PC committed
72
73
74
75
76
77
78
79
80
    <xsl:template match="//div[@data-hdoc-type='emphasis']" priority="4">
        <h3>
            Fondamental : 
            <xsl:if test="h6">
                 <xsl:value-of select="h6"/>
            </xsl:if>
        </h3>
        <div class="border-top-bot">
            <xsl:apply-templates/>
cliclac's avatar
cliclac committed
81
82
        </div>
    </xsl:template>
Asus-PC's avatar
css  
Asus-PC committed
83
84
85
86
87
88
89
90
91
92
    
    <xsl:template match="//div[@data-hdoc-type='definition']" priority="4">
        <h3>
            Définition : 
            <xsl:if test="h6">
                <xsl:value-of select="h6"/>
            </xsl:if>
        </h3>
        <div class="border-top-bot">
            <xsl:apply-templates/>
cliclac's avatar
cliclac committed
93
94
95
        </div>
    </xsl:template>

Asus-PC's avatar
css  
Asus-PC committed
96
97
98
99
100
101
102
103
104
105
106
107
    <xsl:template match="//div[@data-hdoc-type='remark']" priority="4">
        <h3>
            Remarque : 
            <xsl:if test="h6">
                <xsl:value-of select="h6"/>
            </xsl:if>
        </h3>
        <div>
            <xsl:apply-templates/>
        </div>
    </xsl:template>
    
cliclac's avatar
cliclac committed
108
    <xsl:template match="//div[@data-hdoc-type='complement']" priority="4">
Asus-PC's avatar
css  
Asus-PC committed
109
110
111
112
113
114
115
116
        <h3>
            Complément : 
            <xsl:if test="h6">
                <xsl:value-of select="h6"/>
            </xsl:if>
        </h3>
        <div>
            <xsl:apply-templates/>
cliclac's avatar
cliclac committed
117
118
119
120
        </div>
    </xsl:template>

    <xsl:template match="//div[@data-hdoc-type='example']" priority="4">
Asus-PC's avatar
css  
Asus-PC committed
121
122
123
124
125
126
127
128
        <h3>
            Exemple : 
            <xsl:if test="h6">
                <xsl:value-of select="h6"/>
            </xsl:if>
        </h3>
        <div>
            <xsl:apply-templates/>
cliclac's avatar
cliclac committed
129
130
        </div>
    </xsl:template>
cliclac's avatar
cliclac committed
131
132
    
    <xsl:template match="//div[@data-hdoc-type='syntax']" priority="4">
Asus-PC's avatar
css  
Asus-PC committed
133
134
135
136
137
138
139
140
        <h3>
            Syntaxe : 
            <xsl:if test="h6">
                <xsl:value-of select="h6"/>
            </xsl:if>
        </h3>
        <div>
            <xsl:apply-templates/>
cliclac's avatar
cliclac committed
141
142
        </div>
    </xsl:template>
cliclac's avatar
cliclac committed
143
144

    <xsl:template match="//div[@data-hdoc-type='warning']" priority="4">
Asus-PC's avatar
css  
Asus-PC committed
145
146
        <h3>
            Attention : 
cliclac's avatar
cliclac committed
147
            <xsl:if test="h6">
Asus-PC's avatar
css  
Asus-PC committed
148
                <xsl:value-of select="h6"/>
cliclac's avatar
cliclac committed
149
            </xsl:if>
Asus-PC's avatar
css  
Asus-PC committed
150
151
152
        </h3>
        <div>
            <xsl:apply-templates/>
cliclac's avatar
cliclac committed
153
154
        </div>
    </xsl:template>
cliclac's avatar
cliclac committed
155
156
    
    <xsl:template match="//div[@data-hdoc-type='advice']" priority="4">
Asus-PC's avatar
css  
Asus-PC committed
157
158
159
160
161
162
163
164
        <h3>
            Conseil : 
            <xsl:if test="h6">
                <xsl:value-of select="h6"/>
            </xsl:if>
        </h3>
        <div>
            <xsl:apply-templates/>
cliclac's avatar
cliclac committed
165
166
167
        </div>
    </xsl:template>
    
cliclac's avatar
cliclac committed
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
    <xsl:template match="//div[@data-hdoc-type='description']" priority="4">
        <h4>
            Description :
        </h4>
        <div>
            <xsl:apply-templates/>
        </div>
    </xsl:template>
    
    <xsl:template match="//div[@data-hdoc-type='question']" priority="4">
        <h4>
            Question :
        </h4>
        <div>
            <xsl:apply-templates/>
        </div>
    </xsl:template>
    
    <xsl:template match="//div[@data-hdoc-type='solution']" priority="4">
        <h4>
            Solution :
        </h4>
        <div>
            <xsl:apply-templates/>
        </div>
    </xsl:template>
    
cliclac's avatar
cliclac committed
195
196
197
198
    <xsl:template match="//span[@data-hdoc-type='syntax']" priority="4">
        <span class="bold"><xsl:value-of select="."/></span>
    </xsl:template>
    
Asus-PC's avatar
Asus-PC committed
199
    <xsl:template match="//img" priority="4"> 
Asus-PC's avatar
css  
Asus-PC committed
200
        <img width="300px">
Asus-PC's avatar
Asus-PC committed
201
202
            <xsl:attribute name="src">../images/<xsl:value-of select="./@alt"/></xsl:attribute>
            <xsl:attribute name="alt"><xsl:value-of select="./@alt"/></xsl:attribute>
Asus-PC's avatar
css  
Asus-PC committed
203
        </img>
cliclac's avatar
cliclac committed
204
205
206
207
208
209
210
211
212
213
214
215
    </xsl:template>
    
    <xsl:template match="//a[not(starts-with(@href,'http'))]" priority="4">
        <xsl:element name="a">
            <xsl:attribute name="href">http://<xsl:value-of select="@href"/></xsl:attribute>
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>
    
    <xsl:template match="//object[@type='application/vnd.oasis.opendocument.graphics']" priority="4">
        Élément non supporté en EPUB : <xsl:value-of select="@data"/>
    </xsl:template>
cliclac's avatar
cliclac committed
216

217
218
219
220
    <!-- Identity transformation -->
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
221
222
223
224
        </xsl:copy>
    </xsl:template>

    <!-- Namespace substitution for hdoc elements -->
225
226
227
228
    <xsl:template match="*" priority="1">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="node()|@*"/>
        </xsl:element>
229
230
231
232
    </xsl:template>


</xsl:stylesheet>