This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: grouping adjacent siblings
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] grouping adjacent siblings
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Thu, 3 May 2001 17:31:06 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
> I am trying to transform the following...
>
> <frag>
> <b>house</b>
> <a>door</a>
> <a>wall</a>
> <a>room</a>
> <b>barn</b>
> <a>hay</a>
> <a>cow</a>
> <a>poo</a>
> </frag>
>
You can do this with something like
<xsl:for-each select="b">
<xsl:variable name="id" select="generate-id()"/>
<xsl:apply-templates/>
<xsl:for-each
select="following-sibling::a[generate-id(preceding-sibling::b[1])=$id]">
<xsl:apply-templates/>
</xsl:for-each>
</xsl:for-each>
Mike Kay
Software AG
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list