This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
loop in creation of table
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] loop in creation of table
- From: "Yang" <sfyang at unisvr dot net dot tw>
- Date: Thu, 27 Sep 2001 13:08:20 +0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi, Praveen
I would like to point you to the reference
http://sources.redhat.com/ml/xsl-list/2001-07/msg01845.html
where Dimitre have presented a more generic approach for the type of
problem.
Since his xslt is to written for table presentation row by row,
the xslt for table which data shown column by column is modified as
following;
** xslt list ***
<xsl:output method="html"/>
<xsl:param name="numCols" select="4"/>
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
<table>
<xsl:apply-templates mode="multiColumn"
select="/parent-of-subsystem_id/subsystem_id[position() <=$numCols]">
<xsl:with-param name="numCols" select="$numCols"/>
<xsl:with-param name="nodes"
select="/parent-of-subsystem_id/subsystem_id"/>
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template mode="multiColumn" match="subsystem_id">
<xsl:param name="numCols" select="1"/>
<xsl:param name="nodes" select="/.."/>
<xsl:variable name="vCurPosition" select="position()"/>
<xsl:variable name="vmode" select="position() mod $numCols"/>
<xsl:choose>
<xsl:when test="$vCurPosition mod 2 = 1">
<tr bgcolor="aqua">
<xsl:apply-templates mode="normal"
select="$nodes[position() >= $vCurPosition and
position() mod $numCols = $vmode]" />
</tr>
</xsl:when>
<xsl:when test="$vCurPosition mod 2 = 0">
<tr bgcolor="red">
<xsl:apply-templates mode="normal"
select="$nodes[position() >= $vCurPosition and
position() mod $numCols= $vmode]"
/>
</tr>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="subsystem_id" mode="normal">
<td><xsl:value-of select="."/></td>
</xsl:template>
</xsl:stylesheet>
Cheers,
Sun-fu Yang
sfyang@unisvr.net.tw
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list