Re: RE: [xsl] HTML Table

Subject: Re: RE: [xsl] HTML Table
From: v.kavanagh@xxxxxxxxxxxx
Date: Wed, 3 Sep 2003 17:24:02 +0000
Hi,

Thanks for your replies.

This is the HTML table I?m trying to draw;
<TABLE>
  <TR>
    <TD>abc123</TD>
    <TD>abc345</TD>
    <TD>abc567</TD>
    <TD>abc543</TD>
    <TD>abc987</TD>
    <TD>abc912</TD>
  </TR>
  <TR>
    <TD></TD>
    <TD>429</TD>
    <TD></TD>
    <TD>430</TD>
    <TD></TD>
    <TD>105</TD>
  </TR>
  <TR>
    <TD></TD>
    <TD></TD>
    <TD></TD>
    <TD>434</TD>
    <TD></TD>
    <TD></TD>
    </TR>
</TABLE>

This is an example of the xml;
<root>
 <box BoxID="123" BoxRef="abc123"/>
 <box BoxID="1234" boxref="abc345">
 <tin tinid="429" tinqty="5" tintype="tin"/>
 </box>
 <box BoxID="1267" boxref="abc567"/>
 <box BoxID="1812" boxref="abc543">
 <tin tinid="430" tinqty="10"/>
 <tin tinid="434" tinqty="12"/>
 </box>
 <box BoxID="1813" boxref="abc987"/>
 <box BoxID="1816" boxref="abc912">
 <tin tinid="105" tinqty="10"/>
 </box>
</root>

This is my attempt at the stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="/">		
		<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">
<tr>
<xsl:for-each select="//box/tin">
<xsl:variable name="cur" select="//box/tin/@tinid"/>
<!--<xsl:if test="not(node())"><td></td></xsl:if>-->
  <xsl:if test="//box/tin">
    <xsl:choose>
      <xsl:when test="//box/tin/@tinid">
        <td>
          <xsl:value-of select="@tinid"/>
        </td>
      </xsl:when>
      <xsl:otherwise>
        <td></td>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:if>
</xsl:for-each>
</tr>
 </xsl:for-each>
</table>
  </xsl:template>
</xsl:stylesheet>


Many thanks,


Vince.

-----------------------------------------
Email provided by http://www.ntlhome.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread