RE: Variable references in path expressions

You're quite right. I have since posted a correction.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Bas de Bakker [mailto:bas@x-hive.com] 
> Sent: 26 April 2005 10:54
> To: Michael Kay
> Cc: Charles Brooking; www-ql@w3.org
> Subject: Re: Variable references in path expressions
> 
> I cannot see how the formal semantics requires this. In 
> section 4.8.3 on
> let expressions, there is no mention of re-evaluating the expression
> bound to a variable. A let expression just extends the dynamic
> environment of the return expression with the variable bound to the
> *value* returned by the first expression. The value is then looked up
> multiple times, but this would each time return the same 
> value with the
> same nodes (that is: nodes with the same identity).
> 
> So in this case the path expression de-duplicates 3 copies of $b and
> should return (<b1/>, <b2/>, <b3/>) or an implementation dependent
> permutation of it (because the document order of new nodes is
> implementation dependent).
> 
> Regards,
> 
> Bas de Bakker
> X-Hive Corporation
> 
> 
> Michael Kay wrote:
> >> 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?
> > 
> > Yes.
> > 
> >> Or should (<b1/>, <b2/>, <b3/>) be returned?
> > 
> > No, this would be incorrect. (I can't point you to a 
> discussion of this in
> > the spec; I think the formal semantics handles the issue. 
> But it's certainly
> > been discussed by the WG and it's my clear understanding 
> that the language
> > requires this result.)
> 

Received on Tuesday, 26 April 2005 10:13:55 UTC