It is a common misconception that any XQuery is a FLWOR expression. This misconception comes when people approach XQuery from a SQL perspective, treating it as a SELECT.
This is in fact not the case; a FLWOR expression is in many ways just another expression. It may be that a FLWOR expression is executed as a SQL expression, but this doesn't have to be the case.
XQuery can be viewed as a functional programming language (like Haskell) that happens to have some declarative constructs (like where and order by).
The expression 1+2
is just an XQuery expression that adds the numbers 1 and 2, there does not need to be an implicit FLWOR expression around it.
If you wanted to consider XQuery in a fully tuple-based algebra then you could consider the input to be a single empty tuple. By this I mean the following.
Look at this query:
for $x in ...
for $y in ...
where $x/@name=$y/@name
return $x
If you were considering this in a tuple based algebra, the input to the for expression would be a stream of tuples defining $x
and $y
. It is obvious how this could relate to a database query. This corresponds to a table with two columns $x
and $y
and a row for each pair that have equal names.
You could consider the following query
//foo
as operating on a single tuple with no values. This would be a little bit like a FLWOR expression with no fors or lets (just a return expression, if that were allowed). In relational land this would be a table with no columns and one row. However this is just a logical abstraction, and most (if not all) XQuery implementations represent this as just an expression.