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 ...