RE: [xsl] RE: Postional predicates de-mystified

Subject: RE: [xsl] RE: Postional predicates de-mystified
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 4 Jan 2002 10:20:11 -0000
> >  Evan Lenz wrote:
>
> > The predicate in the second example is not part of the Step,
> > but is part of
> > a more general FilterExpr. In XPath 1.0, a predicate may
> > follow any kind of
> > expression...
>
>
Dave Pawson responded:

> Which seems to be the heart of the matter.
> A quick scan of xpath 2.0 gives a count of node-set about 7
> times (excluding issue related occurences).

Evan's explanation I thought was excellent, but it used the terminology of
XPath 1.0 (which seems approrpriate for its intended audience). The behavior
of these constructs in XPath 2.0 is unchanged, but the terminology used for
explaining the behavior has changed considerably.
>
> This word 'sequence' however, appears to occur slightly more times :-)
>
> <quote>A sequence is an ordered collection of zero or more
> items. An item is either a simple value or a node.</quote>
>
> The 'order' mentioned here, is it document order or can I
> still collect a node-set/sequence in reverse document  order?

A sequence can be in any order. A path expression always returns a sequence
of nodes that are in document order. Other kinds of expression can be used
to obtain nodes in non-document order. For example the expression

  for $i in 1 to count(ancestor::*) return ancestor::*[$i]

will return a sequence containing all the ancestors of the context node, in
reverse document order.


Mike Kay


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


Current Thread