Specify xs: decimal decimal places in XML Schema

  • Is there a way to specify the number of decimal places xs:decimal should have in an XML schema?

  • Is there a way to control the use of .NET Xml*** attributes?

+4
source share
1 answer

You can create a custom type that extends the decimal number and specify the number of digits in fractionDigits as follows:

 <xs:simpleType name="twoPlacesDecimal" id="twoPlacesDecimal"> <xs:restriction base="xs:decimal"> <xs:fractionDigits fixed="true" value="2" /> </xs:restriction> </xs:simpleType> 

You can specify the data type for a property using XmlAttribute(DataType = "value") , but unfortunately this only supports built-in data types. From my reading of the source, if you include a custom data type, you will get an exception.

+3
source

All Articles