Castable expressions

Figure 55. 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 146. Castable as expression

"1" castable as integer
      

Result (run with Zorba): true


Example 147. Castable as expression

"foo" castable as integer
      

Result (run with Zorba): false


Example 148. Castable as expression

"2013-04-02" castable as date
      

Result (run with Zorba): true


Example 149. Castable as expression

() castable as date
      

Result (run with Zorba): false


Example 150. 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 151. Castable as expression

() castable as date?
      

Result (run with Zorba): true