xsd.exe creating invalid constraints in dataset from xsd file

Posted by Dan Neely on Stack Overflow See other posts from Stack Overflow or by Dan Neely
Published on 2009-12-08T14:00:55Z Indexed on 2010/05/03 14:28 UTC
Read the original article Hit count: 264

Filed under:
|
|
|

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>

© Stack Overflow or respective owner

Related posts about c#

Related posts about dataset