In addition to the correct answer @ Michael Kay:
number($x) = number($x)
this expression true() accurate when $x can be used for a number
Here we use the fact that:
If $x not a number, then number($x) by the definition of NaN
NaN not equal to any value, even NaN
Now your last question :
I need to do to copy the value if it is a number and replace it with 99 if it is a string
Using
$x * (number($x) = number($x)) + 99 * not(number($x) = number($x))
The explanation . A boolean value is converted to a number ( true() โ 1, false() โ 0) with a partial expression. In the above expression, one of the + arguments will be 0 , and one will be 1 depending on whether $x / is a number.
source share