tags:

views:

66

answers:

1

i am trying to round a number to 2dp and i am struggling

i am trying to use the decimal-string method

This is what I had

<xf:bind nodeset="/stuff/price" 
    calculate = "if(boolean-from-string(/stuff/amountOff),
    ((/stuff/items) * (/stuff/duration) * 0.8),/stuff/items* /stuff/duration)" />

This is what I tried

<xf:bind 
    nodeset="/stuff/price" 
    calculate = "decimal-string(if(boolean-from-string(/stuff/amountOff),
    ((/stuff/items) * (/stuff/duration) * 0.8),/stuff/items* /stuff/duration)" , 2)/>
+1  A: 

Standard XForms does not support a decimal-string() function, which implementation are you using? The full list of available standard functions can be seen here (notice that it also references XPath 1.0).

Depending on your choice of XForms processor, there may be an extension function that you can use (for instance, formsPlayer exposes the format-number() function from MSXML), or you may have to define your own custom extension (e.g. in javascript) otherwise.

Phil Booth