This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: limiting preceding axis by ancestor
- From: "J.Pietschmann" <j3322ptm at yahoo dot de>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 07 May 2002 22:28:07 +0200
- Subject: Re: [xsl] limiting preceding axis by ancestor
- References: <8DFE59EC652CD51194C60008C75F8C97232A63@mnhs01.mnhs.org>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Fox, Michael wrote:
> I have a document where there are many instances of <foo>. Each <foo> may
> have many <bar> children. <bar> is itself recursive to several levels.
>
> <foo>
> <bar>
> <bar>
> <foo>
> <bar>
> <bar>
> <bar>
>
> I want to test to see if any preceding <bar> has the same value as the
> current <bar> but limit the test to those <bar> elements are children of the
> immediate <foo> ancestor. In other words, I want to exclude any <bar>
> children of the ancestor::foo's preceding-sibling:foo
Try preceding::bar[generate-id()=generate-id(current()/ancestor::foo)]
or ancestor::foo//bar[following::bar[count(.|current())=1]]
Either can be inefficient, depending on the actual XML.
J.Pietschmann
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list