RE: [xsl] Preceding Ancestors

Subject: RE: [xsl] Preceding Ancestors
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Aug 2001 18:29:25 +0200 (MEST)
> n:/s/m/m[2]/p[2]/preceding::p
> <!-- XPATH:/s/m/m[2]/p[2]/preceding::p -->
> <xpath-query query="/s/m/m[2]/p[2]/preceding::p">
> <p a="1" />
> <p a="2" />
> <p a="3" />
> <p a="4" />
> <p a="5" />
> <p a="6" />
> </xpath-query>
> 
> Giving me 3,4,5 where I shouldn't have them :)

Alright, I was too fast with my answer.
Trevor got it right. 
Another solution (extending my proposal): the intersection of your
idea ancestor::*/p and my one preceding::p

This leads to
<xsl:template match="p[@a='7']">
   <xsl:variable name="a" select="ancestor::*/p" />
   <xsl:variable name="p" select="preceding::p" />
   <xsl:copy-of select="$a[count(.|$p)=count($p)]" />
</xsl:template>

and the output
<p a="1"/><p a="2"/><p a="6"/>

Cheers,
Oliver

/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


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


Current Thread