Bonjour à tous,

Je rencontre un problème dans ma XSL.

J'essaie de créer un tableau à 1 ligne / 2 colonnes dans lequel je génère dynamiquement d'autres petits tableaux imbriqués.
Lorsque je suis à ma position 1 (1er noeud), je voudrais créer le début du tableau général (<xsl:if test="position()=1"><table><tr><td></xsl:if>)

PUIS quand j'arrive à mon (nombre de noeud total / 2) je voudrais fermer le <tr> et le <td> créés précédemment, et faire de même pour la seconde colonne...

Mon problème :
Lorsque je fais mon xsl:if je me prends une erreur qui m'oblige à fermer mes balises....... Avez-vous une info pour m'aider à résoudre ce problème ?

Je vous donne mon code XML et XSL

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
<?xml version='1.0'?>
<Categories>
   <Category Name="Cat1">
      <SubCategory Name="SubCategory1">
         <File Name="File1" />
      </SubCategory>
   </Category>
   <Category Name="Cat2">
      <SubCategory Name="SubCategory2">
         <File Name="File2" />
      </SubCategory>
   </Category>
   <Category Name="Cat3">
      <SubCategory Name="SubCategory3">
         <File Name="File3" />
      </SubCategory>
   </Category>
   <Category Name="Cat4">
      <SubCategory Name="SubCategory4">
         <File Name="File4" />
      </SubCategory>
   </Category>   
</Categories>

La XSL :

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="html" />
 
   <xsl:template match="/">
      <xsl:param name="directory">c:\toto\</xsl:param>
      <xsl:param name="nbr_categories">4</xsl:param>
 
      <xsl:variable name="nbr_categories_gauche">
	      <xsl:choose>
	      	<xsl:when test="($nbr_categories mod 2) != 0">
	      		<xsl:value-of select="ceiling($nbr_categories div 2)"/>
	      	</xsl:when>
	      	<xsl:otherwise>
	      		<xsl:value-of select="$nbr_categories div 2"/>
	      	</xsl:otherwise>
	   	  </xsl:choose>
   	  </xsl:variable>      
 
 
      <html>
         <head>
         </head>
 
         <body>
            <TABLE>
               <tr valign="top" height="100%">
                  <td>
                     <table>
                        <tr>
                           <td id="span1col1" valign="top" width="100%">
                              <div>
                                 <xsl:call-template name="build-category-table">
                                    <xsl:with-param name="directory" select="$directory" />
                                    <xsl:with-param name="nbr_cats_gauche" select="$nbr_categories_gauche" />
                                 </xsl:call-template>
                              </div>
                           </td>
                        </tr>
                     </table>
                  </td>
               </tr>
            </TABLE>
         </body>
      </html>
   </xsl:template>
 
   <xsl:template name="build-category-table">
      <xsl:param name="directory" />
      <xsl:param name="nbr_cats_gauche" />
 
      <!--<xsl:if test="position() = 1">
      	<table><tr><td>
      </xsl:if>-->
 
      <table width="100%" border="0" cellpadding="10" cellspacing="0">
         <xsl:call-template name="build-category-row">
            <xsl:with-param name="directory" select="$directory" />
 
            <xsl:with-param name="category-list" select="//Category" />
 
            <xsl:with-param name="column-count" select="2" />
         </xsl:call-template>
      </table>
   </xsl:template>
 
<!-- build row template -->
   <xsl:template name="build-category-row">
      <xsl:param name="directory" />
 
      <xsl:param name="category-list" />
 
      <xsl:param name="column-count" />
 
      <xsl:if test="$category-list">
<!-- Row (tr)-->
         <tr>
            <xsl:call-template name="build-category-columns">
               <xsl:with-param name="directory" select="$directory" />
 
               <xsl:with-param name="category-list" select="$category-list[position() &lt; $column-count + 1]" />
 
               <xsl:with-param name="column-count" select="$column-count" />
            </xsl:call-template>
         </tr>
 
         <xsl:call-template name="build-category-row">
            <xsl:with-param name="directory" select="$directory" />
 
            <xsl:with-param name="category-list" select="$category-list[position()&gt;$column-count]" />
 
            <xsl:with-param name="column-count" select="$column-count" />
         </xsl:call-template>
      </xsl:if>
   </xsl:template>
 
<!-- build columns template -->
   <xsl:template name="build-category-columns">
      <xsl:param name="directory" />
 
      <xsl:param name="category-list" />
 
      <xsl:param name="column-count" />
 
      <xsl:if test="$column-count &gt; 0">
<!-- Column (td)-->
         <td>
            <table>
               <tr>
                  <td>
                     <table>
                        <tr>
                           <th class="title1">
                              <xsl:if test="$category-list">
                                 <xsl:value-of select="$category-list[1]/@Name" />
                              </xsl:if>
                           </th>
                        </tr>                       
                        <tr>
                           <td class="FILE">
                              <xsl:apply-templates select="$category-list[1]/File">
                              	<xsl:with-param name="directory" select="$directory" />
                              </xsl:apply-templates>
                           </td>
                        </tr>
 
                        <tr>
                           <td class="SUBCAT">
                              <xsl:apply-templates select="$category-list[1]/SubCategory">
                              	<xsl:with-param name="directory" select="$directory" />
                              </xsl:apply-templates>
                           </td>
                        </tr>
                     </table>
                  </td>
               </tr>
            </table>
         </td>
 
         <xsl:call-template name="build-category-columns">
            <xsl:with-param name="directory" select="$directory" />
            <xsl:with-param name="category-list" select="$category-list[position() != 1]" />
            <xsl:with-param name="column-count" select="$column-count - 1" />
         </xsl:call-template>
      </xsl:if>
   </xsl:template>
 
   <xsl:template match="SubCategory">
      <xsl:param name="directory" />
 
      <xsl:variable name="subDirectory">
      	<xsl:value-of select="@Name" />
      </xsl:variable>
 
      <xsl:variable name="fullDirectory">
         <xsl:value-of select="concat($directory,$subDirectory)" />
      </xsl:variable>
 
      <tr>
         <td colspan="2" style="font-weight : bold;text-align : center;">
         	<xsl:value-of select="@Name" />
         </td>
      </tr>
 
      <xsl:apply-templates select="File">
         <xsl:with-param name="directory" select="$fullDirectory" />
      </xsl:apply-templates>
   </xsl:template>
 
   <xsl:template match="File">
      <xsl:param name="directory" />
 
      <xsl:variable name="fileName">
         <xsl:value-of select="@Name" />
      </xsl:variable>
 
      <tr>
         <td>
            <table cellSpacing="0" cellPading="0" border="1" width="100%">
               <tr>
                  <td style="padding-left: 5px">
                     <A TARGET="fraContent">
                        <xsl:attribute name="HREF">
                           <xsl:value-of select="concat($directory,$fileName)" />
                        </xsl:attribute>
 
                        <xsl:value-of select="@Name" />
                     </A>
                  </td>
               </tr>
            </table>
         </td>
      </tr>
   </xsl:template>
</xsl:stylesheet>
Merci d'avance pour votre aide !!

++