A variable may be bound by a let clause in a FLWOR expression. The type of the variable is the same as the type of its defining expression. Here are some examples:
let $z := 1+2 return $z+$z has type xs:integer let $z := 1e0+1.0 return $z+$z has type xs:double
In the first let expression, the expression 1+2 has type xs:integer; therefore, the variable $z also has type xs:integer, and the return expression is typed assuming that $z has type xs:integer. Similarly, in the second expression, variable $z has type xs:double. The static type system keeps track of the types of variables in the static environment; whenever a variable is bound, the static environment is extended by associating the variable with the computed type.
The type of ...