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

CORRECTION! (was Re: Assignment no, dynamic scoping si

Subject: CORRECTION! (was Re: Assignment no, dynamic scoping si (was: Re: RE: Wishes for XSL revisions ...)
From: "Evan Lenz" <elenz@xxxxxxxxxxx>
Date: Wed, 2 Jan 2002 14:12:24 -0800
 CORRECTION! (was Re: Assignment no
Doh! My general statement was correct, but my example was wrong. So,
Wendell, sorry to mislead you, but your example in fact was wrong too!

I wrote:
> Unless a predicate is bound (without intervening parentheses) to
> a node test, it is always evaluated with respect to a "forward"
> axis (the XPath spec arbitrarily chooses the child axis).

So far, so good.

> ancestor-or-self::*[@source][last()]
> Your example features both kinds of predicates.

Oops. No, *both* predicates in the above example are tightly bound to the
node test (and thus the reverse axis), because the Step production is as

[4]    Step    ::=    AxisSpecifier NodeTest Predicate*
   | AbbreviatedStep

where the Step itself may have more than one predicate. So [last()] will
select the last node in *reverse* document order (or first in document
order), not the other way around! To get the intended result (getting the
"closest" ancestor), you would either write:




In this second example, the [last()] predicate is no longer tightly bound to
the node test as part of the Step production; the parentheses render it as a
predicate of the second kind--as part of the FilterExpr production:

[20]    FilterExpr    ::=    PrimaryExpr
   | FilterExpr Predicate

And thus [last()] is applied to the result of the expression to the left
with respect to document order, selecting the last node in document order.

Multiple predicates in a reverse step with the last being positional--that
has got to rank pretty highly on the confuse-the-experts list of XPath


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

Current Thread


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.
First Name
Last Name
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.