checking validity before sum()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

checking validity before sum()

Tony Mobbs
I'm trying to add together multiple items entered through a repeat table as follows.

sum(instance('Details')//values)

This all works perfectly well provided that the user enters only numeric values into the cells.

If however the user enters alpha values [a-z], then the application fails with error message "Cannot convert string "abc" to a double".

I've tried a few methods, but they all fail.  One attempt is as follows.

calculate="if ( sum(instance('Details')//values) castable as xs:decimal) then xs:decimal(sum(instance('Details')//values)) else 0" />

It seems that I either need to trap the error to prevent the sum occurring or testing that each element is castable as xs:decimal prior to performing the sum.

Any ideas?




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws