Performing extra data conversion for double values (by XQuery)
Thursday, 21 April 2022 · 2 messages
ME
Markus Elfring21 Apr 2022 09:20 #
Hello,
I would like to perform a sanity check for some input data which represent numbers that are using the comma as the decimal separator.
I stumbled on the message “[FORG0001] Cannot convert to xs:double: …” then according to the evaluation of another XQuery script by the software “BaseX 9.7”. https://docs.basex.org/wiki/XQuery_Errors#Functions_Errors
Can any functions help with the safe handling of currency values for my use case? https://docs.basex.org/wiki/Conversion_Module
Regards,
Markus
MH
Martin Honnen21 Apr 2022 09:26 #
Quoted text · Markus Elfring · 5 lines
On 21.04.2022 09:20, Markus Elfring wrote: > > I would like to perform a sanity check for some input data which represent numbers > that are using the comma as the decimal separator. > I stumbled on the message “[FORG0001] Cannot convert to xs:double: …”
Depending on the format of the numeric data it might suffice to use e.g.
. => translate(',$', '.') => xs:decimal()
to remove e.g. a $ symbol/currency symbol, to replace the comma with a dot and then to convert the numerical string to an xs:decimal value.
Written for BaseX 9.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery