[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Count Ancestors Up To But Not Including a Given Type
Subject: Re: [xsl] Count Ancestors Up To But Not Including a Given Type
From: Eliot Kimber <ekimber@xxxxxxxxxxxx>
Date: Tue, 05 Feb 2008 11:04:13 -0600
|
David Carlisle wrote:
<xsl:sequence select="$n,$n/ancestor::*[node-name(.)=$lists][1][node-name(.)=node-name($n)]/f:same(.)"/>
It took my aging brain a bit to parse this out but I was able to adapt
it to my code to get the correct answer. Here's how I understand this to
work:
1. Construct a sequence consisting of the current node (which we know to
be the starting list) and the results of steps 2-5:
2. Get the list of ancestors that are lists of any type:
ancestor::*[node-name(.)=$lists]
3. Get the first (nearest) such ancestor:
ancestor::*[node-name(.)=$lists][1]
4. For that nearest ancestor, see if its type is the same as the target
type: [node-name(.)=node-name($n)]
5. If it is, apply f:same() to it: /f:same(.)
6. Return the result sequence
Cheers,
Eliot
--
Eliot Kimber
Senior Solutions Architect
"Bringing Strategy, Content, and Technology Together"
Main: 610.631.6770
www.reallysi.com
www.rsuitecms.com
|