slide 56

Expressions Concerning Typing

cast as Creates a new value of a specific type based on an existing value
input-expression cast as target-type
     5 cast as integer 
castable as Tests if a given value can be cast into a given target type without error. Returns boolean.
expression castable as target-type
$size castable as xs:integer  
instance of Returns boolean if the value of the first operand matches the type given in the second operand
     3 instance of xs:integer
would return “ true
treat as At run time, here is the type you should have; postpone all checking till then, and fail then if the type is wrong. The idea is to make static checking work until dynamic checking cuts in at runtime. May be useful for elements that can have two very different potential models (an integer or the code words "not applicable"; quantity-on-hand as a number or as the word “out-of-stock”, any Address or a more restricted “United States Address”, etc.)
$myaddress treat as element(*, USAddress)