Subject: Re: [xsl] loop in creation of table From: Jörg Heinicke <joerg.heinicke@xxxxxx> Date: Thu, 27 Sep 2001 01:33:09 +0200 |
In my eyes there is a better way to reach the same: <xsl:template match="parent-of-subsystem_id"> <table border="1"> <tr><xsl:apply-templates select="subsystem_id[position() mod 4 = 1]"/></tr> <tr><xsl:apply-templates select="subsystem_id[position() mod 4 = 2]"/></tr> <tr><xsl:apply-templates select="subsystem_id[position() mod 4 = 3]"/></tr> <tr><xsl:apply-templates select="subsystem_id[position() mod 4 = 0]"/></tr> </table> </xsl:template> <xsl:template match="subsystem_id"> <td><xsl:value-of select="."/></td> <xsl:if test="position()=last()"> <td colspan="{16 - position()}"> </td> </xsl:if> </xsl:template> </xsl:stylesheet> I like to avoid <call-template>s ;-) Joerg ----- Original Message ----- From: Zwetselaar M. van (Marco) To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Sent: Wednesday, September 26, 2001 4:11 PM Subject: RE: [xsl] loop in creation of table Praveen, > elements like this- <subsystem_id> value1</subsystem_id>. > now i have to design a table like the one shown BELOW.. we > have total of 16 columns and 4 rows. You could do this at follows, but there will surely be more elegant solutions: <xsl:template match="/"> <xsl:call-template name="make-row"> <xsl:with-param name="elements" select="//subsystem_id[position() mod 4 = 1]" /> </xsl:call-template> <xsl:call-template name="make-row"> <xsl:with-param name="elements" select="//subsystem_id[position() mod 4 = 2]" /> </xsl:call-template> <xsl:call-template name="make-row"> <xsl:with-param name="elements" select="//subsystem_id[position() mod 4 = 3]" /> </xsl:call-template> <xsl:call-template name="make-row"> <xsl:with-param name="elements" select="//subsystem_id[position() mod 4 = 0]" /> </xsl:call-template> </xsl:template> <xsl:template name="make-row"> <xsl:param name="elements" /> <tr> <xsl:for-each select="$elements"> <td><xsl:value-of select="." /></td> </xsl:for-each> <td colspan="{16-count($elements)}" /> </tr> </xsl:template> Regards, Marco XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] loop in creation of table, Zwetselaar M. van (M | Thread | [xsl] loop in creation of table, Yang |
Re: [xsl] Element Declaration -- AN, Jörg Heinicke | Date | RE: [xsl] So what xsl processors ar, timw |
Month |