xsl-list
[Top] [All Lists]

Re: Iterating over all the Ancestors

2002-11-26 16:20:31
Bix,

At 05:36 PM 11/26/2002, you wrote:
Suppose I wanted to stop at a given node or after a certain number of ancestors. What would I do to tweak your original solution?

It depends on your criteria. It can get a bit tricky since this is a reverse axis, so e.g. select="ancestor-or-self::*[position < last()] gets all but the document element (the last of the ancestor elements going up).

select="ancestor::*[position <= 3] gets your first three ancestors (but not your context node).

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
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
======================================================================


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>