xsl-list
[Top] [All Lists]

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

2010-11-30 11:10:01

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.)



--~------------------------------------------------------------------
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>
--~--