W3C home > Mailing lists > Public > public-qt-comments@w3.org > December 2011

[Bug 15044] [XQuery30] group by variables with associated expressions

From: <bugzilla@jessica.w3.org>
Date: Sun, 11 Dec 2011 19:00:55 +0000
To: public-qt-comments@w3.org
Message-Id: <E1RZodr-0003OR-IV@jessica.w3.org>

--- Comment #4 from Jonathan Robie <jonathan.robie@gmail.com> 2011-12-11 19:00:54 UTC ---
(In reply to comment #3)

> In the current wording, the question does not appear to be addressed. To answer
> it, I think we'd have to make some changes in the preamble of 3.10.1 "Variable
> Bindings", including "group by" and putting it on the same footing as "for",
> "let", and "count".

How's this:

The following clauses in FLWOR expressions bind values to variables: for, let,
window, count, and group by. The binding of variables for for, let, and count
is governed by the following rules (the binding of variables in window clauses
is discussed in 3.10.4 Window Clause, the binding of variables in group by
clauses is discussed in 3.10.7 Group By Clause):

> ----------------------------------------------
> Consider another example:
>     group by $g1 := $expr1, $g1 := $expr2
> (Note that $g1 appears twice.) Is this legal, and if so, what does it mean?
> In Andrew's proposal, the example transforms to:
>     let $g1 := $expr1
>     let $g1 := $expr2
>     group by $g1, $g1
> The let clauses are certainly legal (the second $g1 occludes the first). The
> group by clause would then have two references to the latter $g1 (and so would
> be equivalent to just "group by $g1").
> If we go with the current wording plus changes to 3.10.1,
>     group by $g1 := $expr1, $g1 := $expr2
> would be legal, but (unlike with Andrew's proposal) the two $g1 would be bound
> to different values, and so provide two grouping keys.
> Or we could add a rule that the variables in a GroupingSpecList must have
> different names.

I think the governing principle here is this: 

A given variable may be bound more than once in a FLWOR expression, or even
within one clause of a FLWOR expression. In such a case, each new binding
occludes the previous one, which becomes inaccessible in the remainder of the
FLWOR expression.

I think that means that the two $g1 bindings are bound to different values,
grouping works correctly, the first value of $g1 is not available to subsequent

That seems fine to me. It's analogous to:

let $a := 1,
    $a := 2
return $a

If that's not an error, I don't think group by $g1 := $expr1, $g1 := $expr2
should be an error.

Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Sunday, 11 December 2011 19:00:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:37 UTC