RE: [xsl] Selecting a range of siblings between specified elements: resend

Subject: RE: [xsl] Selecting a range of siblings between specified elements: resend
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Mon, 8 Mar 2004 14:21:34 -0000

> I'm currently a little puzzled on how to select a range of 
> siblings between 
> specified elements, e.g.
> 
> <?xml version="1.0"?>
> <doc>
> <a>cont1</a><b/><b/>
> <a>cont2</a><b/><b/>
> <a>cont3</a><b/><b/><c/><c/>
> <a>cont4</a><b/><b/><c/><c/>
> </doc>
> 
> 
> I would like to select firstly the <b/><b/> of
> 
> <a>cont1</a><b/><b/>
> 
> then the <b/><b/> of
> 
> <a>cont2</a><b/><b/>

<xsl:template match="a">
  <xsl:apply-templates select="following-sibling::b[
                        generate-id(preceding-sibling::a[1]) 
                        = generate-id(current())
                        ]"/>
</xsl:template>

This roughly translated means for every <a> apply templates to every
following <b> whose nearest preceding-sibling <a> is that <a>. 

cheers
andrew

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


Current Thread