This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Turning off 'well-formedness'
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 10 Jan 2002 11:33:26 -0000
- Subject: RE: [xsl] Turning off 'well-formedness'
- Reply-to: xsl-list at lists dot mulberrytech dot com
> I am trying to create the following marked-up tags using
> MSXML3 on an IE5.x
> browser:
>
> <td>
> data1 <br />
> data2 <br />
> data3 <br />
> </td>
> <td>
> data4 <br />
> data5 <br />
> data6 <br />
> </td>
> ----------------------------------------------------------
> my source file looks like:
>
> <Data>
> <Record>data</Record>
> <Record>data</Record>
> <Record>data</Record>
> <Record>data</Record>
> <Record>data</Record>
> <Record>data</Record>
> </Data>
> ----------------------------------------------------------
This is a common requirement and the usual XSLT 1.0 solution is:
<xsl:template match="Record[position() mod 3 = 1]">
<td>
<xsl:for-each select=".|following-sibling::Record[position() < 3]">
<xsl:value-of select="."/><br/>
</xsl:for-each>
</td>
</xsl:template>
<xsl:template match="Record"/>
In XSLT 2.0 you can do
<xsl:template match="Data">
<xsl:for-each-group group-starting-at="Record[position() mod 3 = 1]">
<td>
<xsl:for-each select="current-group()">
<xsl:value-of select="."/><br/>
</
</
</
</
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list