Hi Bonnie,
I thought this was the other way around - i.e. that the default value is *only* applied if an empty element exists (and if the element does not exist then specifying a default value won't create the element). But I agree my view doesn't seem to be supported by the evidence in this case :-{
FWIW I also think it's the opposite of that with attributes - ie an attribute with a default value will be created if neccessary...
Maybe Dimitry can post a XSD / XML snippet that demonstrates the problem ?
>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.