[xsl] loop in creation of table

Subject: [xsl] loop in creation of table
From: "Yang" <sfyang@xxxxxxxxxxxxx>
Date: Thu, 27 Sep 2001 13:08:20 +0800
Hi,  Praveen

I would like to point you to the reference


 where Dimitre have presented a more generic approach for the type of

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

**   xslt   list  ***
<xsl:output method="html"/>
<xsl:param name="numCols" select="4"/>
<xsl:output omit-xml-declaration="yes"/>
    <xsl:template match="/">
        <xsl:apply-templates mode="multiColumn"
select="/parent-of-subsystem_id/subsystem_id[position() &lt;=$numCols]">
          <xsl:with-param name="numCols" select="$numCols"/>
          <xsl:with-param name="nodes"

<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:when test="$vCurPosition mod 2  = 1">
          <tr bgcolor="aqua">
            <xsl:apply-templates mode="normal"
                      select="$nodes[position() >= $vCurPosition and
position() mod $numCols = $vmode]" />
        <xsl:when test="$vCurPosition mod 2 = 0">
          <tr bgcolor="red">
            <xsl:apply-templates mode="normal"
                      select="$nodes[position() >= $vCurPosition and
position() mod $numCols= $vmode]"

    <xsl:template match="subsystem_id" mode="normal">
     <td><xsl:value-of select="."/></td>


Sun-fu Yang


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

Current Thread