XSLT: Conditional variable select and castable as

Published:

Quick simple conditional select when creating a variable in XSLT 2.0. Also shows the castable as check.

<variable
  name="id"
  select="if(id castable as xs:integer) then id else 0"
  />