Reputation: 790
I used xsd.exe on a remote xsd file to generate some C# class definitions. One type is defined as
<xs:element name="amount">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
When I try to deserialize an xml file I get the error:
There is an error in XML document (30, 12). ---> System.FormatException: Input string was not in a correct format.
This only seems to happen when there's a comma used as a grouping separator (i.e 87,000). If I go through and delete the commas wherever there's an error deserialization works fine.
Is there some modification I can make o the xsd to allow for comma grouping? Or better yet a way to allow for it in my code? Trying to parse a decimal in my code with commas works fine, it's just not liking it in the xml file.
Upvotes: 4
Views: 2082
Reputation: 15685
The definition of this datatype defines no restrictions whatsoever on the size of numbers permissible under this datatype. Unless your form processing is prepared to deal with a number thousands of digits long (or even longer), you should use a restriction on the allowed upper and lower limits, and number of digits past the decimal point.
Upvotes: 1
Reputation: 161821
"87,000" does not match the xs:decimal
type.
There is no XSD type that permits commas.
Upvotes: 7