[Home] [By Thread] [By Date] [Recent Entries]
Hi Sam,
I also have similar requirement before. What I did is to design a template to add empty column like the following: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="images"> <table border="3"> <xsl:for-each select="image[position() mod 5 = 1]"> <xsl:text> </xsl:text> <tr> <xsl:for-each select=".|following-sibling::image[position() < 5]"> <td><xsl:value-of select="concat(@name,':',.)"/></td> </xsl:for-each> <xsl:call-template name="gen_blank_table_col"> <xsl:with-param name="col_num"> <xsl:value-of select="5 - (count(.|following-sibling::image[position() < 5]))"/> </xsl:with-param> </xsl:call-template> </tr> </xsl:for-each> <xsl:text> </xsl:text> </table> </xsl:template> <!-- ======================================================================= --> <!-- This template is used to generate blank table col. --> <!-- ======================================================================= --> <xsl:template name="gen_blank_table_col"> <xsl:param name="col_num"/> <xsl:if test="$col_num > 0"> <td> - </td> <xsl:call-template name="gen_blank_table_col"> <xsl:with-param name="col_num"> <xsl:value-of select="$col_num - 1"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> Hope this helps. Regards, JingJun Sam Carleton ei: I have a node set that I need to get into a table with 5 columns and how ever many rows there needs to be. I have the basic code working. The problem I have is the table is not finished when the node set is not a multiple of 5. Here is a same dataset:
|

Cart



