W3C home > Mailing lists > Public > public-qt-comments@w3.org > June 2004

[FS] for clause normalization

From: Per Bothner <per@bothner.com>
Date: Tue, 15 Jun 2004 08:37:11 +0200
Message-ID: <40CE9917.305@bothner.com>
To: public-qt-comments@w3.org

The normalization of FLWOR clauses seems wrong.
Specifically, the 'for' normalization in 4.8.1 following the
sentence:
   Therefore, a ForClause is normalized to nested for expressions:
appears to be incorrect.

Consider:

for $i in 0 to 9 for $j in 0 to 9 stable order by $j return 10*$i+j

This yields the tuple sequence:
(i=0,j=0), (i=0, j=1), (i=0, j=2) ...
so the sorted result should be:
0, 10, 20, ..., 1, 11, 21, ...

The "normalized" expression is:
for $i in 0 to 9 (for $j in 0 to 9 stable order by $j return 10*$i+j)

This performs 10 independents sorts, none of which change the order,
so the result is as if there was no order by clause:
0, 1, 2, ..., 10, 11, 12, ...
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/
Received on Tuesday, 15 June 2004 02:38:54 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:20 UTC