On Mon, Feb 03, 2020 at 08:27:09AM +0100, Martin Honnen scripsit:
Am 03.02.2020 um 01:22 schrieb Graydon Saunders:
for $value in $xmlReport/csv/record/Payment_Amount/number() where ??? return $value
Can you live with
for $value in $xmlReport/csv/record/Payment_Amount where $value castable as xs:double return xs:double($value)
That errors out! [XPTY0004] Cannot convert element()* to xs:double+: $xmlReport_1/element(csv)/element(record)/element(Payment_Amount)[. castable as xs:double]. If I do that with /number() at the end of the XPath for $value in $xmlReport/csv/record/Payment_Amount/number() I get "NaN" as the overall result. I conclude from this that NaN is castable as xs:double which surprised me when I first tried something like this, but which does make sense in as much as NaN has to be pseudo-numeric. If I take the type off the variable: let $made := for $value in $xmlReport/csv/record/Payment_Amount instead of let $made as xs:double+ := for $value in $xmlReport/csv/record/Payment_Amount then it works. Which really surprised me because the whole statement should return a sequence of doubles: let $made as xs:double+ := for $value in $xmlReport/csv/record/Payment_Amount where $value castable as xs:double return $value doesn't strike me as obviously wrongly typed on $made. I'd expect that to fail without the where clause but to be OK with it. Thanks! Graydon