chapitre.xsl 8.84 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
59
                <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>

60
61
62
63
    <xsl:template match="section" priority="3">
        <xsl:element name="h{count(ancestor::section)+1}">
            <xsl:value-of select="header/h1"/>
        </xsl:element>
64
        <xsl:apply-templates select="div|section"/>
65
    </xsl:template>
66

cliclac's avatar
cliclac committed
67
68
69
70
    <xsl:template match="h6" priority="3"/>
    

    <xsl:template match="//div[@data-hdoc-type='remark']" priority="4">
cliclac's avatar
cliclac committed
71
72
73
74
75
76
77
78
79
80
        <div class="noCut">
            <h3>
                <xsl:if test="h6">
                    <span class="textTitle"><xsl:value-of select="h6"/></span>
                </xsl:if>
                <span class="title">Remarque</span>
            </h3>
            <div class="border">
                <xsl:apply-templates/>
            </div>
cliclac's avatar
cliclac committed
81
82
83
84
        </div>
    </xsl:template>

    <xsl:template match="//div[@data-hdoc-type='emphasis']" priority="4">
cliclac's avatar
cliclac committed
85
86
87
88
89
90
91
92
93
94
        <div class="noCut">
            <h3>
                <xsl:if test="h6">
                    <span class="textTitle"><xsl:value-of select="h6"/></span>
                </xsl:if>
                <span class="title">Fondamental</span>
            </h3>
            <div class="border">
                <xsl:apply-templates/>
            </div>
cliclac's avatar
cliclac committed
95
96
97
98
        </div>
    </xsl:template>

    <xsl:template match="//div[@data-hdoc-type='complement']" priority="4">
cliclac's avatar
cliclac committed
99
100
101
102
103
104
105
106
107
108
        <div class="noCut">
            <h3>
                <xsl:if test="h6">
                    <span class="textTitle"><xsl:value-of select="h6"/></span>
                </xsl:if>
                <span class="title">Complément</span>
            </h3>
            <div class="border">
                <xsl:apply-templates/>
            </div>
cliclac's avatar
cliclac committed
109
110
111
112
        </div>
    </xsl:template>

    <xsl:template match="//div[@data-hdoc-type='example']" priority="4">
cliclac's avatar
cliclac committed
113
114
115
116
117
118
119
120
121
122
        <div class="noCut">
            <h3>
                <xsl:if test="h6">
                    <span class="textTitle"><xsl:value-of select="h6"/></span>
                </xsl:if>
                <span class="title">Example</span>
            </h3>
            <div class="border">
                <xsl:apply-templates/>
            </div>
cliclac's avatar
cliclac committed
123
124
        </div>
    </xsl:template>
cliclac's avatar
cliclac committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
    
    <xsl:template match="//div[@data-hdoc-type='syntax']" priority="4">
        <div class="noCut">
            <h3>
                <xsl:if test="h6">
                    <span class="textTitle"><xsl:value-of select="h6"/></span>
                </xsl:if>
                <span class="title">Syntaxe</span>
            </h3>
            <div class="border">
                <xsl:apply-templates/>
            </div>
        </div>
    </xsl:template>
cliclac's avatar
cliclac committed
139
140

    <xsl:template match="//div[@data-hdoc-type='warning']" priority="4">
cliclac's avatar
cliclac committed
141
142
143
144
145
146
147
148
149
150
        <div class="noCut">
            <h3 class="warning">
            <xsl:if test="h6">
                <span class="textTitle"><xsl:value-of select="h6"/></span>
            </xsl:if>
            <span class="title">Attention</span>
            </h3>
            <div class="borderWarning">
                <xsl:apply-templates/>
            </div>
cliclac's avatar
cliclac committed
151
152
        </div>
    </xsl:template>
cliclac's avatar
cliclac committed
153
154
155
156
157
158
159
160
161
162
163
164
165
166
    
    <xsl:template match="//div[@data-hdoc-type='advice']" priority="4">
        <div class="noCut">
            <h3>
                <xsl:if test="h6">
                    <span class="textTitle"><xsl:value-of select="h6"/></span>
                </xsl:if>
                <span class="title">Conseil</span>
            </h3>
            <div class="border">
                <xsl:apply-templates/>
            </div>
        </div>
    </xsl:template>
cliclac's avatar
cliclac committed
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
    
    <xsl:template match="//div[@data-hdoc-type='definition']" priority="4">
        <div class="noCut">
            <h3>
                <xsl:if test="h6">
                    <span class="textTitle"><xsl:value-of select="h6"/></span>
                </xsl:if>
                <span class="title">Définition</span>
            </h3>
            <div class="border">
                <xsl:apply-templates/>
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="//span[@data-hdoc-type='syntax']" priority="4">
        <span class="bold"><xsl:value-of select="."/></span>
    </xsl:template>
    
    <xsl:template match="//img" priority="4">
Asus-PC's avatar
Asus-PC committed
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
        <!--<div class="imageWrapperHi">
            <xsl:element name="img">
                <xsl:attribute name="src">../images/<xsl:value-of select="./@alt"/></xsl:attribute>
                <xsl:attribute name="alt"><xsl:value-of select="./@alt"/></xsl:attribute>
            </xsl:element>
        </div>-->
        
        
        <div class="imgContainer1">
            <div class="imgContainer2">
                    <xsl:element name="img">
                        <xsl:attribute name="src">../images/<xsl:value-of select="./@alt"/></xsl:attribute>
                        <xsl:attribute name="alt"><xsl:value-of select="./@alt"/></xsl:attribute>
                    </xsl:element>
                
            </div>
        </div>
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>