This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: filtering by ancestor
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: KRokicki at genelogic dot com
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Wed, 12 Jun 2002 22:21:42 +0100
- Subject: Re: [xsl] filtering by ancestor
- Organization: Jeni Tennison Consulting Ltd
- References: <OF67E2FE81.8E0113FB-ON85256BD6.00712FC9-85256BD6.0078ACC4@genelogic.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Konrad,
> I'm writing a breadth-first parser but I want to restrict the parse to
> /resultset/result[1]
> So at any given node I need the subset of following::* that has
> /resultset/result[1] as an ancestor.
You could use:
following::*[ancestor::result[generate-id() =
generate-id(/resultset/result[1])]]
which says "find the elements following this node that have as an
ancestor a result element whose unique ID is the same as the unique ID
of /resultset/result[1]".
Since /resultset/result[1] is static, it would be best to store that
(or its generated ID) in a variable rather than calculating it for
each ancestor result of each following element from the current node:
<xsl:variable name="result"
select="generate-id(/resultset/result[1])" />
and then:
following::*[ancestor::result[generate-id() = $result]]
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list