I'm very new to XSL and I'm trying to build a table in the following structure:
I am using this XML:
<CARS>
<CAR>
<CAR_NUM>65</CAR_NUM>
<DRIVERS>
<DRIVER>
<DRIVER_NUM>123</DRIVER_NUM>
<DRIVER_NAME>STEVE RODGERS</DRIVER_NAME>
</DRIVER>
</DRIVERS>
<STATS>
<STAT>
<LAP>1</LAP>
<TIME>3:21:10</TIME>
</STAT>
<STAT>
<LAP>2</LAP>
<TIME>3:21:07</TIME>
</STAT>
</STATS>
</CAR>
<CAR>
<CAR_NUM>22</CAR_NUM>
<DRIVERS>
<DRIVER>
<DRIVER_NUM>143</DRIVER_NUM>
<DRIVER_NAME>TONY STARK</DRIVER_NAME>
</DRIVER>
<DRIVER>
<DRIVER_NUM>155</DRIVER_NUM>
<DRIVER_NAME>JAMES RHODES</DRIVER_NAME>
</DRIVER>
</DRIVERS>
<STATS>
<STAT>
<LAP>1</LAP>
<TIME>3:22:39</TIME>
</STAT>
<STAT>
<LAP>2</LAP>
<TIME>3:19:17</TIME>
</STAT>
<STAT>
<LAP>3</LAP>
<TIME>3:15:46</TIME>
</STAT>
<STAT>
<LAP>4</LAP>
<TIME>3:17:22</TIME>
</STAT>
</STATS>
</CAR>
</CARS>
It is not possible to have more drivers than laps. The nesting of the table by CAR NUMBER is screwing everything up for me because I do not know how to generate blank fields recursively (I'm guessing) using XSL.
I know my first attempt is way off but here it is...
<table>
<xsl:for-each select="CARS/CAR">
<tr>
<td><xsl:value-of select="CAR_NUM"/>
</td>
<xsl:for-each select="DRIVERS/DRIVER">
<td><xsl:value-of select="DRIVER_NUM"/>
</td>
<td><xsl:value-of select="DRIVER_NAME"/>
</td>
</xsl:for-each>
<xsl:for-each select="STATS/STAT">
<td><xsl:value-of select="LAP"/>
</td>
<td><xsl:value-of select="TIME"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
This attempt results in:
65 123 STEVE RODGERS 1 3:21:10 2 3:21:07
22 143 TONY STARK 155 JAMES RHODES 1 3:22:39 2 3:19:17 3 3:15:46 4 3:17:22
I can't account for how the empty cells and rows will be created in the processing of looping it.
EDIT: Researching it I believe I need to analyze the XML as hierarchy tiers:
Tier 1: CAR_NUM
Tier 2: DRIVER_NUM, DRIVER_NAME
Tier 3: LAP, TIME
I need to nest a couple if's after running the first record:
T1->T2->T3 - End the row, then test for next record in T2 (if found go to T2)
T2->T3 - End the row, then test for next record in T2 (if not found, go T3)
T3