I have a very simple XML schema I am trying to read into DataSet. When I read the schema file, the DataSet ignores the totalDigits and fractionalDigits restrictions. The string's max length restriction is respected, but I can't get it to acknowledge the decimal restrictions. Here is the xsd file:
<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="NewDataSet" >
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Sample">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" minOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="32" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Latitude" minOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="15" />
<xs:fractionDigits value="8" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
And here is some quick and dirty sample code that reads the schema and outputs the relevant fields.
DataSet ds = new DataSet();
ds.ReadXmlSchema( @"C:\sample.xsd" );
var rows = ds.CreateDataReader().GetSchemaTable().AsEnumerable();
foreach(var row in rows)
{
string colName = row.Field<string>("ColumnName");
Type type = row.Field<Type>("DataType");
object size = row["ColumnSize"];
object precision = row["NumericPrecision"];
object scale = row["NumericScale"];
Console.WriteLine(String.Format("{0}: {1} <{2}> <{3}> <{4}>",
colName,
type,
size,
precision,
scale));
}
Finally, here is the output:
Name: String <32> <> <>
Latitude: Decimal <-1> <> <>
How can I properly specify the decimal's precision and scale?