Bonjour,

je souhaite transformer un fichier XML de facon a obtenir un resultat similaire au défi de septembre 2004, a savoir je veux regrouper mes salles par noms et ne pas afficher plus de 5 colonnes par tableau. Si le nombre de salle est superieur a cinq on crée un nouveau tableau.

Voici un extrait de mon fichier XML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
<?xml version="1.0" encoding="UTF-8"?>
<fiche_technique>
  <chapitre nom="Aménagement">
    <espace nom="B301" date-short="25/01/2006" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B301" date-short="26/01/2006" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B301" date-short="26/01/2006bis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B301" date-short="27/01/2006" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006bis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006bisbis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006Test" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006Testbis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006Testbisbis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006Testbisbisbis" horaire-debut="" horaire-fin="">
    </espace>
  </chapitre>
  <chapitre nom="Technique Audio Visuel">
    <espace nom="B301" date-short="25/01/2006" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B301" date-short="26/01/2006" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B301" date-short="26/01/2006bis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B301" date-short="27/01/2006" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006bis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006bisbis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006Test" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006Testbis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006Testbisbis" horaire-debut="" horaire-fin="">
    </espace>
    <espace nom="B302" date-short="25/01/2006Testbisbisbis" horaire-debut="" horaire-fin="">
    </espace>
  </chapitre>
</fiche_technique>
et voici mon bout de code Xslt
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:set="http://exslt.org/sets">
	<xsl:output method="html" indent="no" encoding="ISO-8859-1"/>
	<xsl:param name="fichierXML"/>
	<xsl:param name="responsescrolly"/>
	<xsl:template match="/">
		<html>
			<head>
				<title>Fiche Technique</title>
			</head>
			<body>
<h1>Aménagement/Technique-Audio Visuel  </h1>
<xsl:for-each select="fiche_technique/chapitre[@nom='Technique Audio Visuel']/espace">
 <xsl:if test="position() mod 5 = 1 or preceding-sibling::*[1]/@nom!=@nom ">
	<xsl:call-template name="compteurTechAudioEntete">
	    <xsl:with-param name="tableau" select="position()"/> 
	    <xsl:with-param name="espace" select="@nom"/>
        </xsl:call-template>
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
 
<!-- template compteur compteurTechAudioEntete -->
	<xsl:template name="compteurTechAudioEntete">
 	<xsl:param name="tableau" />
 	<xsl:param name="espace" />
 	<table> 		
		<xsl:call-template name="compteurTechAudio">
			<xsl:with-param name="N" select="1"/>
			<xsl:with-param name="O" select="1"/>
			<xsl:with-param name="nomespace" select="$espace"/>
			<xsl:with-param name="M" select="$tableau"/>
		</xsl:call-template>		
	</table>
	<br/>		
 	</xsl:template>
 <!-- fin du template compteur compteurTechAudioEntete -->