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

[XQuery] "Cartesian product"

From: Michael Dyck <jmdyck@ibiblio.org>
Date: Thu, 12 Feb 2004 14:20:55 -0800
To: public-qt-comments@w3.org
Message-id: <402BFC47.2330B9F8@ibiblio.org>

XQuery 1.0: An XML Query Language
W3C Working Draft 12 November 2003

3.8.1. For and Let Clauses

"A for clause may also contain multiple variables, each with an
associated expression. In this case, the for clause iterates each
variable over the items that result from evaluating its expression.
The resulting tuple stream contains one tuple for each combination of
values in the Cartesian product of the sequences resulting from
evaluating the given expressions."

The second sentence only makes sense if the expressions are independent.

Consider a case where they are not:
  for $x in (10,20),
      $y in ($x + 1, $x + 2)
  return 2 * $y

In the two For clauses, the first expression yields (10,20),
and the second expression yields (11,12) and (21,22) in turn.
So "the sequences resulting from evaluating the given expressions"
are (10,20), (11,12), and (21,22). Their Cartesian product is
this set of combinations:
which is not at all what you intended.  Of course, this is a willful
misinterpretation. My claim is that, when the expressions are not
independent, it is the only interpretation available.  Presumably,
the intent is that [$x,$y] take on the values:
but this is not a Cartesian product.

I made much the same comment almost three years ago in:

(Personally, I think the whole "tuple stream" model of explaining
FLWOR expressions is an unnecessary complication, but I doubt that
I could convince you to abandon it.)


3.11 Quantified Expressions

This section has a similar sentence involving the term "Cartesian
product", which is similarly flawed.

-Michael Dyck
Received on Thursday, 12 February 2004 17:29:17 UTC

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