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: Preceding Ancestors


> 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


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