xsd.exe creating invalid constraints in dataset from xsd file
- by Dan Neely
I have a sequence with an allowed minimum length of zero in my xsd. When I try and load an xml file which doesn't have any elements of the sequence into the DataSet that xsd.exe created I get an exception indicating that my file violated one of the DataSet's constraints. The xml file validates against the schema so I know it's valid. Is there anything I can do to make the tool generate a valid dataset?
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Numbers" type="xs:double"/>
</xs:sequence>
Edit: if I change my schema to this the generated code works properly. It looks wrong to me though since it appears to be implying that I could have sequence items with nothing in them, which doesn't make any sense.
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Numbers" type="xs:double" minOccurs="0"/>
</xs:sequence>