Re: [xsl] display problem

Subject: Re: [xsl] display problem
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Thu, 31 Jan 2002 11:22:04 +0100
Hello Shahid,

you have to access every third node, to create a new <tr>. Then you have to
access this and the next 2 <count>s to create the <td>s.

<xsl:template match="test">
    <table>
        <xsl:apply-templates select="count[position() mod 3 = 1]"
mode="tablerow"/>
    </table>
</xsl:template>

<xsl:template match="count" mode="tablerow">
    <tr>
        <xsl:apply-templates select=". | following-sibling::count[position()
&lt; 3]"/>
    </tr>
</xsl:template>

<xsl:template match="count">
    <td><xsl:value-of select="name"/></td>
</xsl:template>

Of course, you can parameterize this stylesheet. Add a toplevel-param with
the count of cols you want to have and replace the both '3' by the name of
the param.

Regards,

Joerg

----- Original Message -----
From: "Shahid Mahmood" <shahid@xxxxxxxxxxx>
To: <xsL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, January 31, 2002 7:48 AM
Subject: [xsl] display problem


> Hi All
>
> I am a newcomer in XSL. I have a problem with displaying xml. I want an
> output of xml such as
>
> <TABLE>
>  <TR>
>   <TD>1</TD>
>   <TD>2</TD>
>   <TD>3</TD>
>  </TR>
>  <TR>
>   <TD>4</TD>
>   <TD>5</TD>
>   <TD>6</TD>
>  </TR>
>  <TR>
>   <TD>7</TD>
>   <TD>8</TD>
>
>  </TR>
> </TABLE>
>
>
> here is the xml file
>   <test>
>        <count>
>            <name>1</name>
>        </count>
>        <count>
>            <name>2</name>
>        </count>
>        <count>
>            <name>3</name>
>        </count>
>        <count>
>            <name>4</name>
>        </count>
>         <count>
>            <name>5</name>
>        </count>
>        <count>
>            <name>6</name>
>        </count>
>        <count>
>            <name>7</name>
>        </count >
>        <count>
>            <name>8</name>
>        </count>
>
>   </test>
> Thanks.
>
> Shahid Mahmood
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


Current Thread