FLWOR Expressions

The FLWOR expression is the workhorse of XQuery: It allows a user to iterate over sequences of values, compute intermediate results, and conditionally filter values. Like the typing of path expressions, the typing of FLWOR expressions also relies on factored types.

FLWOR expressions iterate over the items in a sequence. Here is an example in which we suppose that $articles has type element(article)+:

for $article in $articles
return $article/end_date - $article/start_date

has type xdt:dayTimeDuration +. To type the body of the for expression, we strip off the occurrence indicator from element(article)+ and type the body of the for expression assuming that $article has type element(article), yielding type xdt:dayTimeDuration ...

Get XQuery from the Experts: A Guide to the W3C XML Query Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.