RE: [xsl] grouping adjacent siblings

Subject: RE: [xsl] grouping adjacent siblings
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 3 May 2001 17:31:06 +0100
> 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


Current Thread