Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Loading dataset from XML with Schema
Message
From
19/03/2010 10:15:29
 
General information
Forum:
ASP.NET
Category:
XML
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01454990
Message ID:
01455707
Views:
34
>Adding minOccurs="0" still didn't do the job. But thank you for the suggestion.

Dmitry, the only point I was making about using minOccurs="0" was that it would allow the XML to Validate if it was missing the req_entry tag, which is what Viv was complaining about.

However, using minOccurs="0" won't work for you because then it definitely doesn't use the default if you omit the req_entry tag (your current schema doesn't specify a minOccurs, and I believe that defaults to "1").

~~Bonnie

>
>>Viv,
>>
>>>If I remove a 'req_entry' element then the XML will not validate against the schema - ie according to the schema that's not allowed.
>>>Also, AFAICS from reading the W3c specs the correct behaviour is as I mentioned before:

>>
>>I've never tried to validate XML, so I didn't do it in this case, but I suspect that if minOccurs="0" is added to the element in the .XSD, then it should validate just fine when the element is missing from the XML.
>>
>><xsd:element name="req_entry" default="false" type="xsd:boolean" minOccurs="0"/>		
>>
>>
>>Sorry that I didn't mention that earlier, but I guess I missed that little tidbit of info. =0(
>>
>>~~Bonnie
>>
>>
>>
>>>Hi,
>>>That's very odd.
>>>If I remove a 'req_entry' element then the XML will not validate against the schema - ie according to the schema that's not allowed.
>>>Also, AFAICS from reading the W3c specs the correct behaviour is as I mentioned before:
>>>
>>>{value constraint} establishes a default or fixed value for an element. If default is specified, and if the element being validated is empty, then the canonical form of the supplied constraint value becomes the schema normalized value of the validated element in the ·post-schema-validation infoset (my italics)
>>>
>>>Looks to me as if .Net has decided to define its own behaviour as far as the DataSet goes - and I guess I can see the reasoning - being able to omit elements could drastically reduce the XML size. But that still means that, even though the XML might create a valid DataSet if you attempt to pre-validate it against the defined schema it will fail :-{
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform