[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Count elements A up to any element B in an axis

Subject: Re: Count elements A up to any element B in an axis
From: Lars Huttar <lars_huttar@xxxxxxx>
Date: Tue, 30 Nov 2010 11:09:46 -0600
Re:  Count elements A up to any element B in an axis
On 11/30/2010 10:09 AM, Christian Roth wrote:
> Effectively, I need to determine the level of a (possibly nested) list I
> (=context node) am at. 
>
> I thought I would do this by counting my ancestor list elements A.
> However, certain elements along that axis establish a new level-counting
> context (e.g. a table cell or a footnote, B), so I only want to count
> until such an element first appears in the ancestor chain.
>
> My current solution is
>
> count( 
>   ancestor-or-self::A[ . >> ancestor::node()[self::B or /][1] ] 
>      )

On 11/30/2010 11:02 AM, David Carlisle wrote:
>
>> .>>  ancestor::node()[zzzzz]
>
> the . >> doesn't appear to be doing anything here is it?
>
> . is always after its ancestors, so it is just checking that some
> ancestors matching the predicate exist, unless i misread it...

So maybe you need

count( 
  ancestor-or-self::A except ancestor-or-self::B[1]/ancestor::A
     )

(The [1] being there only for performance purposes.)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.