Hi André,
I think that BaseX try to match the java type “BigInteger" into a XQuery type "xs:integer” which is not possible when the value is too big.
Exactly, that’s why.
If there’s a chance to write your code in plain XQuery, then I would definitely recommend that. You indicated that you need the result as string: Do you want to check if your input is a valid integer value?
Best, Christian