tomhartland
05-14-2007, 09:11 AM
Hi :)
Don't know if "dynamic XSLT iterations" is the right description, but I couldn't think what else to call it.
I'm attempting to create an HTML table using XSLT, where the number of columns is dependant on the data.
An example of the data will hopefully make it clearer, where the number of scores is variable, therefore all the "scoreX" nodes will be created as required by the data provider.
<root>
<config>
<numscores>3</numscores>
<config>
<data>
<name>Adam</name>
<score1>1</score1>
<score2>2</score2>
<score3>3</score3>
</data>
<data>
<name>Bill</name>
<score1>2</score1>
<score2>4</score2>
<score3>5</score3>
</data>
</root>
This is the HTML I would like to get back out from the XSLT, but I cannot work out how to loop (in this case) 3 times to find "score1", "score2" and "score3"...
<table>
<tr>
<td>Name</td>
<td>Score 1</td>
<td>Score 2</td>
<td>Score 3</td>
</tr>
<tr>
<td>Adam</td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>Bill</td>
<td>2</td>
<td>4</td>
<td>6</td>
</tr>
<table>
Any help or ideas would be appreciated,
Cheers,
Tom :)
Don't know if "dynamic XSLT iterations" is the right description, but I couldn't think what else to call it.
I'm attempting to create an HTML table using XSLT, where the number of columns is dependant on the data.
An example of the data will hopefully make it clearer, where the number of scores is variable, therefore all the "scoreX" nodes will be created as required by the data provider.
<root>
<config>
<numscores>3</numscores>
<config>
<data>
<name>Adam</name>
<score1>1</score1>
<score2>2</score2>
<score3>3</score3>
</data>
<data>
<name>Bill</name>
<score1>2</score1>
<score2>4</score2>
<score3>5</score3>
</data>
</root>
This is the HTML I would like to get back out from the XSLT, but I cannot work out how to loop (in this case) 3 times to find "score1", "score2" and "score3"...
<table>
<tr>
<td>Name</td>
<td>Score 1</td>
<td>Score 2</td>
<td>Score 3</td>
</tr>
<tr>
<td>Adam</td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>Bill</td>
<td>2</td>
<td>4</td>
<td>6</td>
</tr>
<table>
Any help or ideas would be appreciated,
Cheers,
Tom :)