This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Preceding Ancestors
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] Preceding Ancestors
- From: Oliver Becker <obecker at informatik dot hu-berlin dot de>
- Date: Wed, 8 Aug 2001 18:29:25 +0200 (MEST)
- Reply-To: xsl-list at lists dot mulberrytech dot com
> 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@informatik.hu-berlin.de |
| op|qo WWW: http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list