On Tue, 2022-04-26 at 19:54 +0200, Christian Grün wrote:
A side note: I was surprised to see that Saxon EE 10 raises an exception for my example query. It seems that the predicates are swapped, and the comparison is evaluated before the cast check. Maybe the behavior has been adapted in a more recent version. – A workaround is to use the and expression:
<x>a</x>[. castable as xs:integer and . = 21]
This is also not guaranteed. You can, however, write,
[if (. castable as xs:integer) then (. = 21) else false() ]
This one is guaranteed not to raise dynamic errors in the unused expression.
Liam