1 |
Salut tout le monde, je suis nouveau dans le monde du xml et du XSLT.Vu que |
2 |
j'aimerais aider les gars de la doc français, je suis en train d'apprendre |
3 |
le xslt et j'ai quelques questions. |
4 |
|
5 |
Je suis en train de lire le livre XSLT from O'reilly. |
6 |
|
7 |
J'ai quelques question à propos du fichier guide.xsl de swift. |
8 |
|
9 |
À date, je sais comment passer une variable ou un param à un template mais |
10 |
je ne comprend pas comment fonctionne $chid. |
11 |
|
12 |
Est-ce que $chid est en fait Child Axis. |
13 |
À date, c'est comme si $chid était le contenu d'un élément en court de |
14 |
sélection (Context Node). |
15 |
|
16 |
Pr exemple : |
17 |
Code: |
18 |
|
19 |
<!-- Paragraph --> |
20 |
<xsl:template match="p"> |
21 |
<xsl:param name="chid"/> |
22 |
<xsl:choose> |
23 |
<xsl:when test="@class"> |
24 |
<p class="{@class}"> |
25 |
<xsl:apply-templates> |
26 |
<xsl:with-param name="chid" select="$chid"/> |
27 |
</xsl:apply-templates> |
28 |
</p> |
29 |
</xsl:when> |
30 |
<xsl:otherwise> |
31 |
<p> |
32 |
<xsl:apply-templates> |
33 |
<xsl:with-param name="chid" select="$chid"/> |
34 |
</xsl:apply-templates> |
35 |
</p> |
36 |
</xsl:otherwise> |
37 |
</xsl:choose> |
38 |
</xsl:template> |
39 |
|
40 |
Code: |
41 |
|
42 |
Si je comprend bien, ça insert le contenu du <p> </p> venant d'un fichier |
43 |
.xml et ça le met dans <p> </p> pour le future fichier html. |
44 |
|
45 |
Mais comment sait t'il que c'est bien le contenu de <p> ??? |
46 |
|
47 |
Bref, comment on fait pointer $chid sur le bon <p> |
48 |
|
49 |
Code de swift: |
50 |
|
51 |
<?xml version="1.0" encoding="UTF-8"?> |
52 |
|
53 |
<!-- For local usage only --> |
54 |
|
55 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
56 |
version="1.0"> |
57 |
<xsl:output encoding="UTF-8" method="html" indent="yes" |
58 |
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/> |
59 |
|
60 |
<!-- When using <pre>, whitespaces should be preserved --> |
61 |
<xsl:preserve-space elements="pre"/> |
62 |
|
63 |
<!-- Global definition of style parameter --> |
64 |
<xsl:param name="style">0</xsl:param> |
65 |
|
66 |
<!-- img tag --> |
67 |
<xsl:template match="img"> |
68 |
<img src="{@src}"/> |
69 |
</xsl:template> |
70 |
|
71 |
<!-- Layout de la documentation online--> |
72 |
<xsl:template name="doclayout"> |
73 |
<html> |
74 |
<head> |
75 |
<link title="new" rel="stylesheet" href="css/main.css" type="text/css"/> |
76 |
<link REL="shortcut icon" HREF="favicon.ico" TYPE="image/x-icon"/> |
77 |
<title>Gentoo Linux Documentation Québec |
78 |
-- |
79 |
<xsl:value-of select="title"/> |
80 |
</title> |
81 |
</head> |
82 |
<body style="margin-left:0px;margin-top:0px;" bgcolor="#ffffff"> |
83 |
|
84 |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
85 |
<tr> |
86 |
<td valign="top" height="125" bgcolor="#45347b"> |
87 |
<table cellspacing="0" cellpadding="0" border="0" width="193"> |
88 |
<tr> |
89 |
<td class="logobg" valign="top" align="center" height="88"> |
90 |
<a href="/"><img border="0" src="images/gtop-s.jpg" alt="Gentoo |
91 |
Logo"/></a> |
92 |
</td> |
93 |
</tr> |
94 |
<tr> |
95 |
<td class="logobg" valign="top" align="center" height="36"> |
96 |
<a href="/"><img border="0" src="images/gbot-s.gif" alt="Gentoo |
97 |
Logo Side"/></a> |
98 |
</td> |
99 |
</tr> |
100 |
</table> |
101 |
</td> |
102 |
</tr> |
103 |
<!-- Fin de l'entete avec le logo et Gentoo en mauve --> |
104 |
<tr> |
105 |
<td valign="top" align="right" colspan="1" bgcolor="#ffffff"> |
106 |
<table border="0" cellspacing="0" cellpadding="0" width="100%"> |
107 |
<tr> |
108 |
<td width="99%" class="content" valign="top" align="left"> |
109 |
<!-- C'est ici le coeur de la page --> |
110 |
<xsl:call-template name="content"/> |
111 |
</td> |
112 |
<td width="1%" bgcolor="#dddaec" valign="top"> |
113 |
<table border="0" cellspacing="5" cellpadding="0"> |
114 |
<tr> |
115 |
<td> |
116 |
<img src="images/line.gif" alt="line"/> |
117 |
</td> |
118 |
</tr> |
119 |
<tr> |
120 |
<td align="center" class="alttext"> |
121 |
<!-- Update datestamp --> |
122 |
Updated <xsl:value-of select="/guide/date|/book/date"/> |
123 |
</td> |
124 |
</tr> |
125 |
<tr> |
126 |
<td> |
127 |
<img src="images/line.gif" alt="line"/> |
128 |
</td> |
129 |
</tr> |
130 |
<tr> |
131 |
<td class="alttext"> |
132 |
<!-- Authors --> |
133 |
<xsl:apply-templates select="/guide/author|/book/author"/> |
134 |
</td> |
135 |
</tr> |
136 |
<tr> |
137 |
<td> |
138 |
<img src="images/line.gif" alt="line"/> |
139 |
</td> |
140 |
</tr> |
141 |
<tr> |
142 |
<td class="alttext"> |
143 |
<!-- Abstract (summary) of the document --> |
144 |
<b>Sommaire:</b> <xsl:apply-templates select="abstract"/> |
145 |
</td> |
146 |
</tr> |
147 |
<tr> |
148 |
<td> |
149 |
<img src="images/line.gif" alt="line"/> |
150 |
</td> |
151 |
</tr> |
152 |
</table> |
153 |
</td> |
154 |
</tr> |
155 |
</table> |
156 |
</td> |
157 |
</tr> |
158 |
<tr> |
159 |
<td colspan="2" align="right" class="infohead" width="100%" |
160 |
bgcolor="#7a5ada"> |
161 |
Copyright 2006 Gentoo-Québec Email <a class="highlight" |
162 |
href="mailto:info@×××××××××××××.org">info@×××××××××××××.org</a>. |
163 |
</td> |
164 |
</tr> |
165 |
|
166 |
</table> |
167 |
|
168 |
</body> |
169 |
</html> |
170 |
</xsl:template> |
171 |
|
172 |
<!-- Mail template --> |
173 |
<xsl:template match="mail"> |
174 |
<a href="mailto:{@link}"><xsl:value-of select="."/></a> |
175 |
</xsl:template> |
176 |
|
177 |
<!-- Mail inside <author>...</author> --> |
178 |
<xsl:template match="/book/author/mail"> |
179 |
<b> |
180 |
<a class="altlink" href="mailto:{@link}"><xsl:value-of select="."/></a> |
181 |
</b> |
182 |
</xsl:template> |
183 |
|
184 |
<!-- Affiche le nom de l'auteur avec son email --> |
185 |
<xsl:template match="author"> |
186 |
<xsl:apply-templates/> |
187 |
<xsl:if test="@title"> |
188 |
<xsl:if test="$style != 'printable'"> |
189 |
<br/> |
190 |
</xsl:if> |
191 |
<i><xsl:value-of select="@title"/></i> |
192 |
</xsl:if> |
193 |
<br/> |
194 |
<xsl:if test="$style != 'printable'"> |
195 |
<br/> |
196 |
</xsl:if> |
197 |
</xsl:template> |
198 |
|
199 |
<!-- Section template --> |
200 |
<xsl:template match="section"> |
201 |
<xsl:param name="chid"/> |
202 |
<xsl:if test="title"> |
203 |
<xsl:variable name="sectid">doc_chap<xsl:value-of |
204 |
select="$chid"/>_sect<xsl:number/></xsl:variable> |
205 |
<xsl:if test="@id"> |
206 |
<a name="{@id}"/> |
207 |
</xsl:if> |
208 |
<p class="secthead"> |
209 |
<a name="{$sectid}"><xsl:value-of select="title"/> </a> |
210 |
</p> |
211 |
</xsl:if> |
212 |
<xsl:apply-templates select="body"> |
213 |
<xsl:with-param name="chid" select="$chid"/> |
214 |
</xsl:apply-templates> |
215 |
</xsl:template> |
216 |
|
217 |
<!-- Figure template --> |
218 |
<xsl:template match="figure"> |
219 |
<xsl:param name="chid"/> |
220 |
<xsl:variable name="fignum"><xsl:number level="any" from="chapter" |
221 |
count="figure"/></xsl:variable> |
222 |
<xsl:variable name="figid">doc_chap<xsl:value-of |
223 |
select="$chid"/>_fig<xsl:value-of select="$fignum"/></xsl:variable> |
224 |
<br/> |
225 |
<a name="{$figid}"/> |
226 |
<table cellspacing="0" cellpadding="0" border="0"> |
227 |
<tr> |
228 |
<td class="infohead" bgcolor="#7a5ada"> |
229 |
<p class="caption"> |
230 |
<xsl:choose> |
231 |
<xsl:when test="@caption"> |
232 |
Figure <xsl:value-of select="$chid"/>.<xsl:value-of |
233 |
select="$fignum"/>: <xsl:value-of select="@caption"/> |
234 |
</xsl:when> |
235 |
<xsl:otherwise> |
236 |
Figure <xsl:value-of select="$chid"/>.<xsl:value-of |
237 |
select="$fignum"/> |
238 |
</xsl:otherwise> |
239 |
</xsl:choose> |
240 |
</p> |
241 |
</td> |
242 |
</tr> |
243 |
<tr> |
244 |
<td align="center" bgcolor="#ddddff"> |
245 |
<xsl:choose> |
246 |
<xsl:when test="@short"> |
247 |
<img src="{@link}" alt="Fig. {$fignum}: {@short}"/> |
248 |
</xsl:when> |
249 |
<xsl:otherwise> |
250 |
<img src="{@link}" alt="Fig. {$fignum}"/> |
251 |
</xsl:otherwise> |
252 |
</xsl:choose> |
253 |
</td> |
254 |
</tr> |
255 |
</table> |
256 |
<br/> |
257 |
</xsl:template> |
258 |
|
259 |
<!--figure without a caption; just a graphical element--> |
260 |
<xsl:template match="fig"> |
261 |
<center> |
262 |
<xsl:choose> |
263 |
<xsl:when test="@linkto"> |
264 |
<a href="{@linkto}"><img border="0" src="{@link}" alt="{@short}"/></a> |
265 |
</xsl:when> |
266 |
<xsl:otherwise> |
267 |
<img src="{@link}" alt="{@short}"/> |
268 |
</xsl:otherwise> |
269 |
</xsl:choose> |
270 |
</center> |
271 |
</xsl:template> |
272 |
|
273 |
<!-- Line break --> |
274 |
<xsl:template match="br"> |
275 |
<br/> |
276 |
</xsl:template> |
277 |
|
278 |
<!-- Note --> |
279 |
<xsl:template match="note"> |
280 |
<table class="ncontent" width="100%" border="0" cellspacing="0" |
281 |
cellpadding="0"> |
282 |
<tr> |
283 |
<td bgcolor="#bbffbb"> |
284 |
<p class="note"> |
285 |
<b>Note: </b> |
286 |
<xsl:apply-templates/> |
287 |
</p> |
288 |
</td> |
289 |
</tr> |
290 |
</table> |
291 |
</xsl:template> |
292 |
|
293 |
<!-- Important item --> |
294 |
<xsl:template match="impo"> |
295 |
<table class="ncontent" width="100%" border="0" cellspacing="0" |
296 |
cellpadding="0"> |
297 |
<tr> |
298 |
<td bgcolor="#ffffbb"> |
299 |
<p class="note"> |
300 |
<b>Important: </b> |
301 |
<xsl:apply-templates/> |
302 |
</p> |
303 |
</td> |
304 |
</tr> |
305 |
</table> |
306 |
</xsl:template> |
307 |
|
308 |
<!-- Warning --> |
309 |
<xsl:template match="warn"> |
310 |
<table class="ncontent" width="100%" border="0" cellspacing="0" |
311 |
cellpadding="0"> |
312 |
<tr> |
313 |
<td bgcolor="#ffbbbb"> |
314 |
<p class="note"> |
315 |
<b>Attention: </b> |
316 |
<xsl:apply-templates/> |
317 |
</p> |
318 |
</td> |
319 |
</tr> |
320 |
</table> |
321 |
</xsl:template> |
322 |
|
323 |
<!-- Code note --> |
324 |
<xsl:template match="codenote"> |
325 |
<span class="comment">// <xsl:value-of select="."/></span> |
326 |
</xsl:template> |
327 |
|
328 |
<!-- Regular comment --> |
329 |
<xsl:template match="comment"> |
330 |
<span class="comment"> |
331 |
<xsl:apply-templates/> |
332 |
</span> |
333 |
</xsl:template> |
334 |
|
335 |
<!-- User input --> |
336 |
<xsl:template match="i"> |
337 |
<span class="input"><xsl:apply-templates/></span> |
338 |
</xsl:template> |
339 |
|
340 |
<!-- Bold --> |
341 |
<xsl:template match="b"> |
342 |
<b><xsl:apply-templates/></b> |
343 |
</xsl:template> |
344 |
|
345 |
<!-- Brite --> |
346 |
<xsl:template match="brite"> |
347 |
<font color="#ff0000"> |
348 |
<b><xsl:apply-templates/></b> |
349 |
</font> |
350 |
</xsl:template> |
351 |
|
352 |
<!-- Body inside email --> |
353 |
<xsl:template match="/email/body"> |
354 |
<table border="0"> |
355 |
<tr> |
356 |
<td> |
357 |
<span class="content"> |
358 |
<p class="secthead"> |
359 |
Subject: <xsl:value-of select="/email/subject"/> |
360 |
</p> |
361 |
<p class="secthead"> |
362 |
<font color="#000000"> |
363 |
List: <xsl:value-of select="/email/list"/> at gentoo.org<br/> |
364 |
Date: <xsl:value-of select="/email/date"/><br/> |
365 |
From: <xsl:value-of select="/email/from"/><br/><br/> |
366 |
<xsl:if test="/email/nav/prev"> |
367 |
<xsl:for-each select="/email/nav/prev[position()=1]/text()"> |
368 |
<xsl:variable name="navloc" select="."/> |
369 |
<xsl:variable name="navfile">/dyn/lists/<xsl:value-of |
370 |
select="/email/list"/>/<xsl:value-of select="."/>.xml</xsl:variable> |
371 |
Previous: <a href="{$navfile}"><xsl:value-of |
372 |
select="document($navfile)/email/subject"/></a><br/> |
373 |
</xsl:for-each> |
374 |
</xsl:if> |
375 |
<xsl:if test="/email/nav/next"> |
376 |
<xsl:for-each select="/email/nav/next[position()=1]/text()"> |
377 |
<xsl:variable name="navloc" select="."/> |
378 |
<xsl:variable name="navfile">/dyn/lists/<xsl:value-of |
379 |
select="/email/list"/>/<xsl:value-of select="."/>.xml</xsl:variable> |
380 |
Next: <a href="{$navfile}"><xsl:value-of |
381 |
select="document($navfile)/email/subject"/></a><br/> |
382 |
</xsl:for-each> |
383 |
</xsl:if> |
384 |
<xsl:if test="/email/in-reply-to"> |
385 |
<xsl:for-each |
386 |
select="/email/in-reply-to[position()=1]/text()"> |
387 |
<xsl:variable name="irtloc" select="."/> |
388 |
<xsl:variable name="irtfile">/dyn/lists/<xsl:value-of |
389 |
select="/email/list"/>/<xsl:value-of select="."/>.xml</xsl:variable> |
390 |
In Reply To: <a href="{$irtfile}"><xsl:value-of |
391 |
select="document($irtfile)/email/subject"/></a><br/> |
392 |
</xsl:for-each> |
393 |
</xsl:if> |
394 |
<xsl:if test="/email/replies"> |
395 |
<br/>Replies to this message:<br/> |
396 |
<xsl:for-each select="/email/replies/reply/text()"> |
397 |
<xsl:variable name="rloc" select="."/> |
398 |
<xsl:variable name="rfile">/dyn/lists/<xsl:value-of |
399 |
select="/email/list"/>/<xsl:value-of select="."/>.xml</xsl:variable> |
400 |
<a href="{$rfile}"><xsl:value-of |
401 |
select="document($rfile)/email/subject"/></a><br/> |
402 |
</xsl:for-each> |
403 |
</xsl:if> |
404 |
</font> |
405 |
</p> |
406 |
</span> |
407 |
<pre> |
408 |
<xsl:apply-templates/> |
409 |
</pre> |
410 |
</td> |
411 |
</tr> |
412 |
</table> |
413 |
</xsl:template> |
414 |
|
415 |
<!-- Body --> |
416 |
<xsl:template match="body"> |
417 |
<xsl:param name="chid"/> |
418 |
<xsl:apply-templates> |
419 |
<xsl:with-param name="chid" select="$chid"/> |
420 |
</xsl:apply-templates> |
421 |
</xsl:template> |
422 |
|
423 |
<!-- Command or input, not to use inside <pre> --> |
424 |
<xsl:template match="c"> |
425 |
<span class="code"><xsl:apply-templates/></span> |
426 |
</xsl:template> |
427 |
|
428 |
<!-- Box with small text --> |
429 |
<xsl:template match="box"> |
430 |
<p class="infotext"><xsl:apply-templates/></p> |
431 |
</xsl:template> |
432 |
|
433 |
<!-- Preserve whitespace, aka Code Listing --> |
434 |
<xsl:template match="pre"> |
435 |
<xsl:param name="chid"/> |
436 |
<xsl:variable name="prenum"><xsl:number level="any" from="chapter" |
437 |
count="pre"/></xsl:variable> |
438 |
<xsl:variable name="preid">doc_chap<xsl:value-of |
439 |
select="$chid"/>_pre<xsl:value-of select="$prenum"/></xsl:variable> |
440 |
<a name="{$preid}"/> |
441 |
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" |
442 |
border="0"> |
443 |
<tr> |
444 |
<td class="infohead" bgcolor="#7a5ada"> |
445 |
<p class="caption"> |
446 |
<xsl:choose> |
447 |
<xsl:when test="@caption"> |
448 |
Code listing <xsl:if test="$chid"><xsl:value-of |
449 |
select="$chid"/>.</xsl:if><xsl:value-of select="$prenum"/>: <xsl:value-of |
450 |
select="@caption"/> |
451 |
</xsl:when> |
452 |
<xsl:otherwise> |
453 |
Code listing <xsl:value-of select="$chid"/>.<xsl:value-of |
454 |
select="$prenum"/> |
455 |
</xsl:otherwise> |
456 |
</xsl:choose> |
457 |
</p> |
458 |
</td> |
459 |
</tr> |
460 |
<tr> |
461 |
<td bgcolor="#ddddff"> |
462 |
<pre> |
463 |
<xsl:apply-templates/> |
464 |
</pre> |
465 |
</td> |
466 |
</tr> |
467 |
</table> |
468 |
</xsl:template> |
469 |
|
470 |
<!-- Path --> |
471 |
<xsl:template match="path"> |
472 |
<span class="path"><xsl:value-of select="."/></span> |
473 |
</xsl:template> |
474 |
|
475 |
<!-- Url --> |
476 |
<xsl:template match="uri"> |
477 |
<!-- expand templates to handle things like <uri |
478 |
link="http://bar"><c>foo</c></uri> --> |
479 |
<xsl:choose> |
480 |
<xsl:when test="@link"> |
481 |
<xsl:choose> |
482 |
<xsl:when test="substring(@link,1,1) = '?'"> |
483 |
<!-- We are dealing with a handbook link --> |
484 |
<xsl:choose> |
485 |
<!-- ?part=X&chap=Y, or ?chap=Y&part=X --> |
486 |
<xsl:when test="starts-with(@link, '?part=')"> |
487 |
<xsl:variable name="thePart" |
488 |
select="substring(substring-before(@link, '&'), 7, 20)"/> |
489 |
<xsl:variable name="theChap" |
490 |
select="substring(substring-after(@link, '&'), 6, 20)"/> |
491 |
<a |
492 |
href="hb_part{$thePart}_chap{$theChap}.html"><xsl:apply-templates /></a> |
493 |
</xsl:when> |
494 |
<xsl:when test="starts-with(@link, '?chap=')"> |
495 |
<xsl:variable name="thePart" |
496 |
select="substring(substring-after(@link, '&'), 6, 20)"/> |
497 |
<xsl:variable name="theChap" |
498 |
select="substring(substring-before(@link, '&'), 7, 20)"/> |
499 |
<a |
500 |
href="hb_part{$thePart}_chap{$theChap}.html"><xsl:apply-templates /></a> |
501 |
</xsl:when> |
502 |
<xsl:otherwise> |
503 |
<a href="{@link}"><xsl:apply-templates /></a> |
504 |
</xsl:otherwise> |
505 |
</xsl:choose> |
506 |
</xsl:when> |
507 |
<xsl:when test="starts-with(@link, '/')"> |
508 |
<a href="http://www.gentoo.org{@link}"><xsl:apply-templates /></a> |
509 |
</xsl:when> |
510 |
<xsl:otherwise> |
511 |
<a href="{@link}"><xsl:apply-templates/></a> |
512 |
</xsl:otherwise> |
513 |
</xsl:choose> |
514 |
</xsl:when> |
515 |
<xsl:otherwise> |
516 |
<xsl:variable name="loc" select="."/> |
517 |
<a href="{$loc}"><xsl:apply-templates/></a> |
518 |
</xsl:otherwise> |
519 |
</xsl:choose> |
520 |
</xsl:template> |
521 |
|
522 |
<!-- Paragraph --> |
523 |
<xsl:template match="p"> |
524 |
<xsl:param name="chid"/> |
525 |
<xsl:choose> |
526 |
<xsl:when test="@class"> |
527 |
<p class="{@class}"> |
528 |
<xsl:apply-templates> |
529 |
<xsl:with-param name="chid" select="$chid"/> |
530 |
</xsl:apply-templates> |
531 |
</p> |
532 |
</xsl:when> |
533 |
<xsl:otherwise> |
534 |
<p> |
535 |
<xsl:apply-templates> |
536 |
<xsl:with-param name="chid" select="$chid"/> |
537 |
</xsl:apply-templates> |
538 |
</p> |
539 |
</xsl:otherwise> |
540 |
</xsl:choose> |
541 |
</xsl:template> |
542 |
|
543 |
<!-- Emphasize --> |
544 |
<xsl:template match="e"> |
545 |
<span class="emphasis"><xsl:apply-templates/></span> |
546 |
</xsl:template> |
547 |
|
548 |
<!-- E-mail address --> |
549 |
<xsl:template match="mail"> |
550 |
<a href="mailto:{@link}"><xsl:value-of select="."/></a> |
551 |
</xsl:template> |
552 |
|
553 |
<!-- Table --> |
554 |
<xsl:template match="table"> |
555 |
<table class="ntable"> |
556 |
<xsl:apply-templates/> |
557 |
</table> |
558 |
</xsl:template> |
559 |
|
560 |
<!-- Table Row --> |
561 |
<xsl:template match="tr"> |
562 |
<tr> |
563 |
<xsl:apply-templates/> |
564 |
</tr> |
565 |
</xsl:template> |
566 |
|
567 |
<!-- Table Item --> |
568 |
<xsl:template match="ti"> |
569 |
<td bgcolor="#ddddff" class="tableinfo"> |
570 |
<xsl:apply-templates/> |
571 |
</td> |
572 |
</xsl:template> |
573 |
|
574 |
<!-- Table Heading --> |
575 |
<xsl:template match="th"> |
576 |
<td bgcolor="#7a5ada" class="infohead"> |
577 |
<b> |
578 |
<xsl:apply-templates/> |
579 |
</b> |
580 |
</td> |
581 |
</xsl:template> |
582 |
|
583 |
<!-- Unnumbered List --> |
584 |
<xsl:template match="ul"> |
585 |
<ul> |
586 |
<xsl:apply-templates/> |
587 |
</ul> |
588 |
</xsl:template> |
589 |
|
590 |
<!-- Ordered List --> |
591 |
<xsl:template match="ol"> |
592 |
<ol> |
593 |
<xsl:apply-templates/> |
594 |
</ol> |
595 |
</xsl:template> |
596 |
|
597 |
<!-- List Item --> |
598 |
<xsl:template match="li"> |
599 |
<li> |
600 |
<xsl:apply-templates/> |
601 |
</li> |
602 |
</xsl:template> |
603 |
|
604 |
<!-- NOP --> |
605 |
<xsl:template match="ignoreinemail"> |
606 |
<xsl:apply-templates/> |
607 |
</xsl:template> |
608 |
|
609 |
<!-- NOP --> |
610 |
<xsl:template match="ignoreinguide"> |
611 |
</xsl:template> |
612 |
|
613 |
<!-- License Tag --> |
614 |
<xsl:template match="license"> |
615 |
<xsl:if test="$style != 'printable'"> |
616 |
<tt> |
617 |
The contents of this document are licensed under the <a |
618 |
href="http://creativecommons.org/licenses/by-sa/1.0">Creative Commons - |
619 |
Attribution / Share Alike</a> license. |
620 |
</tt> |
621 |
</xsl:if> |
622 |
|
623 |
</xsl:template> |
624 |
|
625 |
<!-- Define global variables; if a user has |
626 |
already defined those, this is a NOP --> |
627 |
<xsl:param name="part">0</xsl:param> |
628 |
<xsl:param name="chap">0</xsl:param> |
629 |
|
630 |
<!-- A book --> |
631 |
<xsl:template match="/book"> |
632 |
<!-- If chap = 0, show an index --> |
633 |
<!-- <xsl:message terminate="no"> |
634 |
<xsl:text>On passe dans template /book le premier </xsl:text> |
635 |
</xsl:message> |
636 |
--> |
637 |
<!-- SA 2006-03-26 Debut --> |
638 |
<xsl:if test="$chap = 0"> |
639 |
<xsl:if test="$style = 'printable'"> |
640 |
<xsl:apply-templates select="author" /> |
641 |
</xsl:if> |
642 |
<!-- SA 2006-03-26 fin --> |
643 |
</xsl:if> |
644 |
<xsl:choose> |
645 |
<xsl:when test="$part != 0"> |
646 |
<xsl:apply-templates select="part" /> |
647 |
</xsl:when> |
648 |
<xsl:otherwise> |
649 |
<xsl:choose> |
650 |
<xsl:when test="$style = 'printable'"> |
651 |
<xsl:call-template name="printdoclayout" /> |
652 |
</xsl:when> |
653 |
<xsl:otherwise> |
654 |
<xsl:call-template name="doclayout"/> |
655 |
</xsl:otherwise> |
656 |
</xsl:choose> |
657 |
</xsl:otherwise> |
658 |
</xsl:choose> |
659 |
</xsl:template> |
660 |
|
661 |
<!-- Content of /book --> |
662 |
<xsl:template name="bookcontent"> |
663 |
<xsl:call-template name="menubar" /> |
664 |
<h1><xsl:value-of select="title" /></h1> |
665 |
<xsl:if test="$style = 'printable'"> |
666 |
<xsl:apply-templates select="author" /> |
667 |
</xsl:if> |
668 |
<p>Dans ce chapitre nous allons aborder les points suivants:</p> |
669 |
<ul> |
670 |
<xsl:for-each select="part"> |
671 |
<xsl:variable name="curpart" select="position()" /> |
672 |
<li> |
673 |
<b><a href="hb_part{$curpart}_chap0.html"><xsl:value-of |
674 |
select="title" /></a></b> |
675 |
<xsl:if test="abstract"> |
676 |
<br /> |
677 |
<xsl:value-of select="abstract" /> |
678 |
</xsl:if> |
679 |
<ol> |
680 |
<xsl:for-each select="chapter"> |
681 |
<xsl:variable name="curchap" select="position()" /> |
682 |
<li> |
683 |
<b><a |
684 |
href="hb_part{$curpart}_chap{$curchap}.html"><xsl:value-of select="title" |
685 |
/></a></b> |
686 |
<xsl:if test="abstract"> |
687 |
<br/> |
688 |
<xsl:value-of select="abstract" /> |
689 |
</xsl:if> |
690 |
</li> |
691 |
</xsl:for-each> |
692 |
</ol> |
693 |
</li> |
694 |
</xsl:for-each> |
695 |
</ul> |
696 |
<xsl:call-template name="menubar" /> |
697 |
<xsl:apply-templates select="/book/license" /> |
698 |
</xsl:template> |
699 |
|
700 |
<!-- Part inside a book --> |
701 |
<xsl:template match="/book/part"> |
702 |
<xsl:if test="($chap != 0) and ($part = position())"> |
703 |
<xsl:apply-templates select="chapter" /> |
704 |
</xsl:if> |
705 |
<xsl:if test="($chap = 0) and ($part = position())"> |
706 |
<xsl:choose> |
707 |
<xsl:when test="$style = 'printable'"> |
708 |
<xsl:call-template name="printdoclayout" /> |
709 |
</xsl:when> |
710 |
<xsl:otherwise> |
711 |
<xsl:call-template name="doclayout" /> |
712 |
</xsl:otherwise> |
713 |
</xsl:choose> |
714 |
</xsl:if> |
715 |
</xsl:template> |
716 |
|
717 |
<!-- Content of /book/part --> |
718 |
<xsl:template name="bookpartcontent"> |
719 |
<xsl:call-template name="menubar" /> |
720 |
<xsl:if test="@id"> |
721 |
<a name="{@id}"/> |
722 |
</xsl:if> |
723 |
<h1><xsl:number level="multiple" format="1. " |
724 |
value="position()"/><xsl:value-of select="title" /></h1> |
725 |
<xsl:if test="abstract"> |
726 |
<p><xsl:value-of select="abstract" /></p> |
727 |
</xsl:if> |
728 |
<p>Dans ce chapitre nous allons aborder les points suivants:</p> |
729 |
<ol> |
730 |
<xsl:for-each select="chapter"> |
731 |
<xsl:variable name="curpos" select="position()" /> |
732 |
<xsl:if test="title"> |
733 |
<li> |
734 |
<b><a href="hb_part{$part}_chap{$curpos}.html"><xsl:value-of |
735 |
select="title" /></a></b> |
736 |
<xsl:if test="abstract"> |
737 |
<br/><xsl:value-of select="abstract" /> |
738 |
</xsl:if> |
739 |
</li> |
740 |
</xsl:if> |
741 |
</xsl:for-each> |
742 |
</ol> |
743 |
|
744 |
<xsl:call-template name="menubar" /> |
745 |
<xsl:apply-templates select="/book/license" /> |
746 |
</xsl:template> |
747 |
|
748 |
<!-- Menu bar --> |
749 |
<xsl:template name="menubar"> |
750 |
<!-- SA 2006-03-26 Ajout du if, je veux pas les menus quand j'imprime --> |
751 |
<xsl:if test="$style != 'printable'"> |
752 |
<xsl:variable name="prevpart" select="number($part) - 1" /> |
753 |
<xsl:variable name="prevchap" select="number($chap) - 1" /> |
754 |
<xsl:variable name="nextpart" select="number($part) + 1" /> |
755 |
<xsl:variable name="nextchap" select="number($chap) + 1" /> |
756 |
<hr /> |
757 |
<p class="alttext"> |
758 |
<!-- Previous Parts --> |
759 |
<xsl:choose> |
760 |
<xsl:when test="number($prevpart) < 1"> |
761 |
[ << ] |
762 |
</xsl:when> |
763 |
<xsl:otherwise> |
764 |
[ <a href="hb_part{$prevpart}_chap0.html"><<</a> ] |
765 |
</xsl:otherwise> |
766 |
</xsl:choose> |
767 |
<!-- Previous Chapter --> |
768 |
<xsl:choose> |
769 |
<xsl:when test="number($prevchap) < 1"> |
770 |
[ < ] |
771 |
</xsl:when> |
772 |
<xsl:otherwise> |
773 |
[ <a href="hb_part{$part}_chap{$prevchap}.html"><</a> ] |
774 |
</xsl:otherwise> |
775 |
</xsl:choose> |
776 |
<!-- Content --> |
777 |
[ <a href="index.html">Home</a> ] |
778 |
<!-- Next Chapter --> |
779 |
<xsl:if test="name() = 'book'"> |
780 |
[ <a href="hb_part1_chap0.html">></a> ] |
781 |
</xsl:if> |
782 |
<xsl:if test="name() = 'part'"> |
783 |
[ <a href="hb_part{$part}_chap1.html">></a> ] |
784 |
</xsl:if> |
785 |
<xsl:if test="name() = 'chapter'"> |
786 |
<xsl:choose> |
787 |
<xsl:when test="last() = position()"> |
788 |
[ > ] |
789 |
</xsl:when> |
790 |
<xsl:otherwise> |
791 |
[ <a |
792 |
href="hb_part{$part}_chap{$nextchap}.html">></a> ] |
793 |
</xsl:otherwise> |
794 |
</xsl:choose> |
795 |
</xsl:if> |
796 |
<!-- Next Part --> |
797 |
<xsl:if test="name() = 'book'"> |
798 |
[ <a href="hb_part{$nextpart}_chap0.html">>></a> ] |
799 |
</xsl:if> |
800 |
<xsl:if test="name() = 'part'"> |
801 |
<xsl:choose> |
802 |
<xsl:when test="number($part) = last()"> |
803 |
[ >> ] |
804 |
</xsl:when> |
805 |
<xsl:otherwise> |
806 |
[ <a |
807 |
href="hb_part{$nextpart}_chap0.html">>></a> ] |
808 |
</xsl:otherwise> |
809 |
</xsl:choose> |
810 |
</xsl:if> |
811 |
<xsl:if test="name() = 'chapter'"> |
812 |
<xsl:choose> |
813 |
<xsl:when test="count(/book/part) = number($part)"> |
814 |
[ >> ] |
815 |
</xsl:when> |
816 |
<xsl:otherwise> |
817 |
[ <a href="hb_part{$nextpart}_chap0.html">>></a> |
818 |
] |
819 |
</xsl:otherwise> |
820 |
</xsl:choose> |
821 |
</xsl:if> |
822 |
</p> |
823 |
<hr /> |
824 |
<!-- SA 2006-03-26 Ajout du if, je veux pas les menus quand j'imprime --> |
825 |
</xsl:if> |
826 |
</xsl:template> |
827 |
|
828 |
|
829 |
<!-- Chapter inside a part --> |
830 |
<xsl:template match="/book/part/chapter"> |
831 |
<xsl:if test="$chap = position()"> |
832 |
<xsl:choose> |
833 |
<xsl:when test="$style = 'printable'"> |
834 |
<xsl:call-template name="printdoclayout" /> |
835 |
</xsl:when> |
836 |
<xsl:otherwise> |
837 |
<xsl:call-template name="doclayout" /> |
838 |
</xsl:otherwise> |
839 |
</xsl:choose> |
840 |
</xsl:if> |
841 |
</xsl:template> |
842 |
|
843 |
<!-- Content of /book/part/chapter --> |
844 |
<xsl:template name="bookpartchaptercontent"> |
845 |
<xsl:call-template name="menubar" /> |
846 |
<xsl:if test="@id"> |
847 |
<a name="{@id}"/> |
848 |
</xsl:if> |
849 |
<h1><xsl:number level="multiple" format="1. " |
850 |
value="position()"/><xsl:value-of select="title" /></h1> |
851 |
<xsl:variable name="doc" select="include/@href"/> |
852 |
<xsl:variable name="FILE" select="document($doc)" /> |
853 |
<xsl:if test="$FILE/sections/section/title"> |
854 |
<b>Dans ce chapitre nous allons aborder les points suivants: </b> |
855 |
<ul> |
856 |
<xsl:for-each select="$FILE/sections/section/title"> |
857 |
<xsl:variable name="pos" select="position()" /> |
858 |
<li><a href="#doc_chap{$pos}" class="altlink"><xsl:value-of |
859 |
select="." /></a></li> |
860 |
</xsl:for-each> |
861 |
</ul> |
862 |
</xsl:if> |
863 |
<xsl:apply-templates select="$FILE/sections/section" /> |
864 |
|
865 |
<xsl:call-template name="menubar" /> |
866 |
<xsl:apply-templates select="/book/license" /> |
867 |
</xsl:template> |
868 |
|
869 |
<!-- Section inside a chapter --> |
870 |
<xsl:template match="/sections/section"> |
871 |
<xsl:param name="pos" select="position()" /> |
872 |
<a name="doc_chap{$pos}"/> |
873 |
<xsl:if test="@id"> |
874 |
<a name="{@id}"/> |
875 |
</xsl:if> |
876 |
<xsl:if test="title"> |
877 |
<p class="chaphead"><span class="chapnum"><xsl:value-of select="$chap" |
878 |
/>.<xsl:number level="multiple" format="a. " value="position()" |
879 |
/></span><xsl:value-of select="title" /></p> |
880 |
</xsl:if> |
881 |
<xsl:apply-templates select="body|subsection"> |
882 |
<xsl:with-param name="chpos" select="$pos"/> |
883 |
</xsl:apply-templates> |
884 |
</xsl:template> |
885 |
|
886 |
<!-- Subsubsection inside a section --> |
887 |
<xsl:template match="/sections/section/subsection"> |
888 |
<xsl:param name="pos" select="position()"/> |
889 |
<xsl:param name="chpos" /> |
890 |
<a name="doc_chap{$chpos}_sect{$pos}" /> |
891 |
<xsl:if test="@id"> |
892 |
<a name="{@id}"/> |
893 |
</xsl:if> |
894 |
<p class="secthead"><xsl:value-of select="title" /></p> |
895 |
<xsl:apply-templates select="body" /> |
896 |
</xsl:template> |
897 |
|
898 |
<xsl:template name="content"> |
899 |
<xsl:if test="local-name() = 'book'"> |
900 |
<!-- Inside /book --> |
901 |
<xsl:call-template name="bookcontent" /> |
902 |
</xsl:if> |
903 |
<xsl:if test="local-name() = 'part'"> |
904 |
<!-- Inside /book/part --> |
905 |
<xsl:call-template name="bookpartcontent" /> |
906 |
</xsl:if> |
907 |
<xsl:if test="local-name() = 'chapter'"> |
908 |
<!-- Inside /book/part/chapter --> |
909 |
<xsl:call-template name="bookpartchaptercontent" /> |
910 |
</xsl:if> |
911 |
</xsl:template> |
912 |
|
913 |
<!-- La layout de la version imprimable --> |
914 |
<!-- Printable style for /guide --> |
915 |
<xsl:template name="printdoclayout"> |
916 |
<html> |
917 |
<head> |
918 |
<link title="new" rel="stylesheet" href="css/main.css" type="text/css"/> |
919 |
<title> |
920 |
Version Imprimable |
921 |
<xsl:choose> |
922 |
<xsl:when test="/guide/@type='project'">Projects</xsl:when> |
923 |
<xsl:otherwise>Documentation Gentoo Québec</xsl:otherwise> |
924 |
</xsl:choose> |
925 |
-- |
926 |
<xsl:choose> |
927 |
<xsl:when test="subtitle"><xsl:value-of select="title"/>: |
928 |
<xsl:value-of select="subtitle"/></xsl:when> |
929 |
<xsl:otherwise><xsl:value-of select="title"/></xsl:otherwise> |
930 |
</xsl:choose> |
931 |
</title> |
932 |
</head> |
933 |
<body style="margin-right: 35mm;" bgcolor="#ffffff"> |
934 |
|
935 |
<!-- Content goes here --> |
936 |
<xsl:call-template name="content" /> |
937 |
|
938 |
</body> |
939 |
</html> |
940 |
</xsl:template> |
941 |
|
942 |
</xsl:stylesheet> |
943 |
|
944 |
|
945 |
|
946 |
J'aimerais bien que quelqu'un m'aide là-dessus, car sinon je sais pas trop |
947 |
comment ça fonctionne et je suis pas capable de le modifier pour mon plaisir |
948 |
:) |
949 |
|
950 |
Sylvain Alain |
951 |
|
952 |
|
953 |
-- |
954 |
gentoo-user-fr@g.o mailing list |