This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: grouping adjacent siblings


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]