Product SiteDocumentation Site

5.7.3. Castable expressions

CastableExpr
Figure 5.49. CastableExpr

A castable expression checks whether a JSONiq value can be cast to a given atomic type and returns true or false accordingly. It can be used before actually casting to that type.
Example 5.141. Castable as expression
"1" castable as integer
Result (run with Zorba):
true

Example 5.142. Castable as expression
"foo" castable as integer
Result (run with Zorba):
false

Example 5.143. Castable as expression
"2013-04-02" castable as date
Result (run with Zorba):
true

Example 5.144. Castable as expression
() castable as date
Result (run with Zorba):
false

Example 5.145. Castable as expression
("2013-04-02", "2013-04-03") castable as date
Result (run with Zorba):
false

The question mark allows for an empty sequence.
Example 5.146. Castable as expression
() castable as date?
Result (run with Zorba):
true