W3C home > Mailing lists > Public > www-ql@w3.org > April to June 2005

FW: Re: Variable references in path expressions

From: Michael Kay <mhk@mhk.me.uk>
Date: Tue, 26 Apr 2005 15:05:20 +0100
To: <www-ql@w3.org>
Message-ID: <E1DQQgp-0005kP-Pv@bart.w3.org>

(Resending from the appropriate email address)

Someone has corrected me off-list on part of my answer:

> 
> However, will
> 
>     let
>       $a := (<a1/>, <a2/>, <a3/>),
>       $b := (<b1/>, <b2/>, <b3/>)
>     return
>       $a/$b
> 
> return
> 
>     (<b1/>, <b2/>, <b3/>, <b1/>, <b2/>, <b3/>, <b1/>, <b2/>, <b3/>)
> 
> because the expression bound to $b constructs unique elements 
> each time it is evaluated? 

I answered incorrectly: Yes.

I was thinking of a different case, $a/b() where the function b() returns
three elements. In that case, b() must be evaluated three times, and returns
three different elements each time. With a variable reference, however, the
variable must be evaluated exactly once, and the same value is used each
time. So the result is 
(<b1/>, <b2/>, <b3/>) or some permutation thereof (since these elements are
not in the same tree, their relative document order is unpredictable).

Michael Kay
http://www.saxonica.com/
Received on Tuesday, 26 April 2005 14:05:37 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:17:17 UTC