Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Loading dataset from XML with Schema
Message
 
 
To
18/03/2010 01:08:20
General information
Forum:
ASP.NET
Category:
XML
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01454990
Message ID:
01455317
Views:
34
Bonnie,

You described the content of the XML exactly how it is in my case. To answer your question, the XML simply reside on the drive (I manually created it). And you said it correctly, if the tag is empty, the DataSet should put default instead of the missing tag. But it does not. I don't know why though. I know that the schema file is being Read correctly since the DataSet gets the data types correctly from schema file. I am just thinking that I should try to "play" with other tag default values in this schema to see if they work. I will do that.

Thank you.

>Dmitry,
>
>Possibly the problem is that the boolean element is not really empty, because it's still being specified, even when there's nothing in the element tag.
>
>IOW, you have in your XML an "empty" tag that looks like this:
>
>
><req_entry></req_entry>
>
>or maybe like this:
>
><req_entry />
>
>
>The point is that the XML shouldn't contain the tag at all. Since you have a schema defined, the DataSet should then put the default in for the missing tag. Where did your XML file come from?
>
>~~Bonnie
>
>
>>Hi,
>>
>>I was wondering if anybody can suggest a way around this issue.
>>
>>I created an XML and a schema file (.XSD). The XSD specifies types of all elements in the XML. One of the elements is boolean. The XSD also specifies the default value as following:
>>
>>
>><xsd:element name="req_entry" default="false" type="xsd:boolean"/>		
>>
>>
>>Everything works well.. unless the value in the element "req_entry" in the XML is empty. Then an exception is thrown saying that "The string '' is not a valid Boolean value". I thought that specifying the default value (false) in the schema file will set the value as false. But it does not. Here is the code of how I am loading the XML:
>>
>>
>>DataSet myDataSet = new DataSet();
>>myDataSet.ReadXmlSchema("MySchema.xsd");
>>myDataSet.ReadXml("MyXml.xml");
>>
>>
>>I would appreciate any suggestions.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform