Brandon Sloane created DAFFODIL-2043:
----------------------------------------

             Summary: fn:round-half-to-even returns decimal string
                 Key: DAFFODIL-2043
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2043
             Project: Daffodil
          Issue Type: Bug
            Reporter: Brandon Sloane
         Attachments: test.dfdl.xsd

fn:round-half-to-even() appears to be returning a decimal string, which causes 
issues when an integer type is expected.

The following elements both trigger a schema definition error

<xs:element name="a" type="xs:int"
 dfdl:inputValueCalc="\{ (fn:round-half-to-even( 0.1 )) }"
 />

<xs:element name="a" type="xs:int"
 dfdl:inputValueCalc="\{ xs:int(fn:round-half-to-even( 0.1 )) }"
 />

[error] Schema Definition Error: Cannot convert '0.0' from String type to Long 
(Cannot convert to type long: For input string: "0.0").

In contrast, casting to a double, as below, appears to work as expected:

<xs:element name="a" type="xs:int"
 dfdl:inputValueCalc="\{ xs:double(fn:round-half-to-even( 0.1 )) }"
 />

 

What appears to be happening is that fn:round-half-to-even( 0.1 ) returns the 
string "0.0", and the type="xs:int" on the element triggers an implicit cast to 
an integer type. Since "0.0" contains a decimal point, this cast fail. However, 
an explict cast to xs:double can succeed, and then the explicit cast to an int 
from the double works as expected.

Complete example schema attached



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to