Jarno,
Many thanks that was exactly want I wanted, here is my version:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="root">
<TABLE border="1">
<TR>
<xsl:for-each select="box">
<TH>
<xsl:value-of select="@boxref"
/>
</TH>
</xsl:for-each>
</TR>
<xsl:for-each select="box">
<xsl:sort select="count(tin)"
data-type="number" order="descending"/>
<xsl:if test="position() = 1">
<xsl:for-each select="tin">
<xsl:variable name="position"
select="position()"/>
<TR>
<xsl:for-each
select="../../box">
<TD>
<xsl:variable name="tinno" select="tin[$position]/@tinid"/>
<xsl:variable name="cartno" select="tin[$position]/@cartonid"/>
<xsl:variable name="boxno" select="@boxid"/>
<xsl:variable name="car" select="'car'"/>
<xsl:variable name="tin" select="'tin'"/>
<xsl:variable name="comma" select="','"/>
<xsl:if
test="tin[$position]/@tinid">
<xsl:value-of select="@tinno"/> 
<input type="image" name="removetin" value="remove" src="images/cross.ico"
alt="Remove" onClick="DeleteTin('{(_at_)boxno}','{$tinno}','{$tin}');return
false;"></input>
</xsl:if>
<xsl:if
test="tin[$position]/@cartonid">
<xsl:value-of select="$cartno"/> 
<input type="image" name="removetin" value="remove" src="images/cross.ico"
alt="Remove" onClick="DeleteTin('{$boxno}','{$cartno}','{$car}');return
false;"></input>
</xsl:if>
</TD>
</xsl:for-each>
</TR>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</TABLE>
</xsl:template>
</xsl:stylesheet>
Despite scouring the web for days, I could not find many useful articles on
dynamic HTML creation, are there any sites that are particularly geared towards
this?
Once again many thanks,
Vince.
From: Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com
Date: 2003/09/04 Thu AM 06:35:24 GMT
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: RE: RE: [xsl] HTML Table
Hi,
You want something in the lines of
<xsl:template match="root">
<TABLE>
<TR>
<xsl:for-each select="box">
<TH>
<xsl:value-of select="@boxref" />
</TH>
</xsl:for-each>
</TR>
<xsl:for-each select="box">
<xsl:sort select="count(tin)" data-type="number" order="descending"/>
<xsl:if test="position() = 1">
<xsl:for-each select="tin">
<xsl:variable name="position" select="position()"/>
<TR>
<xsl:for-each select="../../box">
<TD>
<xsl:value-of select="tin[$position]/@tinid"/>
</TD>
</xsl:for-each>
</TR>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</TABLE>
</xsl:template>
I.e. first process the head, then get the max number of tin children in a box
so you know how many rows you need to create, and then loop through the box
elements using the tin that is of the "corresponding index".
Cheers,
Jarno - Bruderschaft: Forever (remix by Feindflug feat. Aeroflot)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
-----------------------------------------
Email provided by http://www.ntlhome.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list