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: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 05 Feb 2008 10:03:35 -0500
Eliot,

How about

(count(ancestor::ol) - count(ancestor::ul/ancestor::ol))?

extending the step "ancestor::ul" to cover other possible intervening elements.

Unlike David's, you do need to know the names of your list-containing elements statically. But then, you do.

(Forgive me if I'm missing something obvious: I'm having trouble connecting with my astral body today.)

Cheers,
Wendell

At 04:52 AM 2/5/2008, you wrote:
> From: Eliot Kimber [mailto:ekimber@xxxxxxxxxxxx]
> Sent: 05 February 2008 07:18
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Count Ancestors Up To But Not Including a Given Type
>
> Maybe it's the lateness of the hour but I'm finding myself
> stymied on what I hope is relatively simple check.
>
> In DITA, as in many doctypes, you can have nested lists of the form:
>
> <ol>
>   <li>
>    <ol>
>     <li>
>     </li>
>    </ol>
>   </li>
> </ol>
>
> As well as an intermixing of different list types, e.g.:
>
> <ol>
>   <li>
>    <ul>
>     <li>
>      <ol>
>       <li>
>
>
> What I need to do is determine, for a given li, its depth of
> nesting within unbroken ancestry of a given list type.
>
> Thus, int the first example, the deepest li is a level 2
> because it has two ancestor <ol> elements with no intervening
> <ul> (or other non-list element that might occur within <li>
> and itself contain a list). In the second example, the
> deepest <li> is a level one because there is an intervening
> <ul> between the two <ol> ancestors.
>
> I can't for the life of me figure out either a single
> expression or a recursive function that will return the
> correct answer.
>
> What bit of logic am I failing to see? I am using XSLT 2.
>
> Thanks,
>
> ELiot
>
> --
> Eliot Kimber
> Senior Solutions Architect
> "Bringing Strategy, Content, and Technology Together"
> Main: 610.631.6770
> www.reallysi.com
> www.rsuitecms.com


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread