When
using the variable declared in an XQuery typeswitch clause in an arithmetic
expression such as in the following example, the processor might incorrectly
report a type error.
typeswitch (.)
case $a as xs:integer return ($a + 1)
default return 17
To work around this limitation,
cast the variable to the expected type. For example:
typeswitch (.)
case $a as xs:integer return (($a cast as xs:integer) + 1)
default return 17