xsl-list
[Top] [All Lists]

Re: [xsl] Count Ancestors Up To But Not Including a Given Type

2008-02-05 10:05:03
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--