O'Reilly logo

XQuery from the Experts: A Guide to the W3C XML Query Language by Philip Wadler, Jim Tivy, Jérôme Siméon, Michael Rys, Jonathan Robie, Michael Kay, Mary Fernández, Denise Draper, Don Chamberlin, Howard Katz - Editor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Variables

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required