Export to XML - Decimal precision

3
The project I'm working for has an implementation to export to XML to talk to an external webservice. The corresponding XSD is made by the external party and cannot be changed by me. For one field, they have the following rules: <xsd:simpleType name="Percentage"> <xsd:restriction base="xsd:decimal"> <xsd:totalDigits value="6"/> <xsd:fractionDigits value="2"/> <xsd:minInclusive value="0"/> <xsd:pattern value="[0-9]{1,4}[.][0-9]{2}"/> </xsd:restriction> </xsd:simpleType> In a previous version of the XSD, the pattern-line was not yet present and everything worked fine. However, now an error is thrown when exporting to XML for whole numbered values (e.g. 100). I've already tried to use a conversionflow (so passing 100.00, round(…,2) or : 1.00 etc.), but it seems that Mendix still rounds to whole numbers afterwards (in the error the value “100” is given).  Is there a way to force decimal precision as I cannot change the given XSD? I already saw this similar question on the forum (https://community.mendix.com/link/questions/89445), but it doesn't mention a solution for my case. Thanks in advance!
asked
1 answers
1

Problem solved itself as asking the external party about this, revealed that they have made an error with creating the XSD.

But for people with similar problems, I've found a work-around in Mendix. You can force Mendix to output with two-decimal precision by adding a conversion flow like below which just passes to the mapping a string (e.g. ‘100.00). The parameter you map to can still be a decimal, so you don't have to change anything in the XSD or in your mapping entities.

answered