Hello,
I'm trying to create a table from an xml file.
The xml is similar to:
<A1>
<subA1 />
<subA2 />
<subA3 />
</A1>
<B1>
</B1>
<C1>
<subC1 />
<subC2 />
</C1>
The table I'm trying to create is:
<TABLE>
<TR>
<TD><xsl:value-of select="@A1"/></TD>
<TD><xsl:value-of select="@B1"/></TD>
<TD><xsl:value-of select="@C1"/></TD></TR>
<TR>
<TD><xsl:value-of select="@subA1"/></TD>
<TD></TD>
<TD><xsl:value-of select="@subC1"/></TD>
</TR>
<TR>
<TD><xsl:value-of select="@subA2"/></TD>
<TD></TD>
<TD><xsl:value-of select="@subC1"/></TD>
</TR>
<TR>
<TD><xsl:value-of select="@subA3"/></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
I have tried :
<table border="1" cellspacing="0">
<!--table header cells -->
<tr>
<tr>Load</tr>
<xsl:for-each select="root/data">
<th>
<xsl:value-of select="@Ref"/>
</th>
</xsl:for-each>
</tr>
<!-- Generate a row for each sub element -->
<xsl:for-each select="root/data">
<xsl:for-each select="sub">
<tr>
<xsl:choose>
<xsl:when test="not(node())"/>
<td></td>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@sub"/>
<input type="button"
onClick="alert(@sub)"></input>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
I am also tring to pass the value of @sub to a script function.
Many thanks,
Vince.
-----------------------------------------
Email provided by http://www.ntlhome.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list