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

Conditionals

A conditional expression consists of a condition and two branch expressions. The condition must be a Boolean. If both branches have the same type, then the type of the conditional expression is also that type. Assume that $x and $y are both integers. Here is an example:

if ($x<$y) then 3 else 4 has type xs:integer

If the two branches have different types, then the type of the conditional expression is the union of those types. Here is an example:

if ($x<$y) then "three" else 4.00 has type (xs:string | xs:decimal)

Recall that in the XQuery formal type notation, a vertical bar indicates the union of two types. The union of a type with itself is just the type, so the rule about conditionals with two branches of the same type is ...

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