Castable expressions

JSONiq follows the W3C standard for ordered and unordered expressions. The following explanations, provided as an informal summary for convenience, are non-normative.

Figure 66. CastableExpr

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 154. Castable as expression

"1" castable as integer
      

Result (run with Zorba): true


Example 155. Castable as expression

"foo" castable as integer
      

Result (run with Zorba): false


Example 156. Castable as expression

"2013-04-02" castable as date
      

Result (run with Zorba): true


Example 157. Castable as expression

() castable as date
      

Result (run with Zorba): false


Example 158. 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 159. Castable as expression

() castable as date?
      

Result (run with Zorba): true