Re: [xsl] reverse and forward order

Subject: Re: [xsl] reverse and forward order
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 11 Apr 2003 14:53:58 -0400
At 10:57 AM 4/11/2003, David wrote:
What Dave means about paremthesese is

ancestor::*[1] gives you the first ancestor in reverse document order
               ie your parent
whereas
(ancestor::*)[1] gives you your first ancestor in document order, ie
                your most ancient ancestor; Adam (or Eve) in some
               cultures.

This leads to a bit of funniness, so that


ancestor::*[1] gives you what Dave says

preceding::*[1] gives you the most recent preceding element

(ancestor::*|preceding::*)[1] gives you the first of the union of both node sets, in document order, namely the document element

so if you want to get the <preceding> element here

<ancestor>
  <preceding>I'm preceding<preceding>
  <node>I'm the context node</node>
</ancestor>

but the <ancestor> element here

<preceding>I'm preceding<preceding>
<ancestor>
  <node>I'm the context node</node>
</ancestor>

you have to do (ancestor::*|preceding::*)[last()]

Cheers,
Wendell


___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_ "Thus I make my own use of the telegraph, without consulting the directors, like the sparrows, which I perceive use it extensively for a perch." -- Thoreau


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



Current Thread