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

IIRC, in my VFP application I have come across cases where the tag was empty but the default value was set based on the schema file. And this is what I expected from .NET Dataset too. Maybe it is a bug in Dataset or maybe "feature" <g>. Thank you.


>Dmitry,
>
>An empty tag is read as being an empty string. And that's not a boolean value. The tag element has to be totally absent, then the default will kick in.
>
>So, instead of this:
>
>	<field>
>		<fld_name>FiscalYear</fld_name>
>		<fld_desc>Fiscal Year</fld_desc>
>		<fld_type>N</fld_type>
>		<fld_len>4</fld_len>
>		<def_value>123</def_value>
>		<req_entry></req_entry>
>	</field>
>
>
>You would have this:
>
>	<field>
>		<fld_name>FiscalYear</fld_name>
>		<fld_desc>Fiscal Year</fld_desc>
>		<fld_type>N</fld_type>
>		<fld_len>4</fld_len>
>		<def_value>123</def_value>
>	</field>
>
>
>This will apply to the numeric fields as well. Even strings, although in your case you defaulted a string element to an empty string anyway, so you wouldn't notice the problem there. Maybe it's a bug in DataSet.ReadXml(), but if there's a way around it, I'm not aware of it.
>
>~~Bonnie
>
>
>>Hi Viv,
>>
>>Here are the files:
>>-- first XSD:
>>
>>
>><?xml version="1.0" encoding="utf-8" ?>
>><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
>>	<xsd:element name="rules">
>>		<xsd:complexType>
>>		<xsd:sequence>
>>	<xsd:element name="field" minOccurs="0" maxOccurs="unbounded">
>>		<xsd:complexType>
>>			<xsd:sequence>
>>				<xsd:element name="fld_name" type="xsd:string"/>
>>				<xsd:element name="fld_desc" type="xsd:string"/>
>>				<xsd:element name="fld_type" type="xsd:string"/>
>>				<xsd:element name="fld_len" default="0" type="xsd:int"/>
>>				<xsd:element name="def_value" default="" type="xsd:string"/>
>>				<xsd:element name="req_entry" default="false" type="xsd:boolean"/>				
>>			</xsd:sequence>
>>		</xsd:complexType>
>>	</xsd:element>
>>		</xsd:sequence>
>>	</xsd:complexType>
>></xsd:element>			
>></xsd:schema>
>>
>>
>>-- And this is XML:
>>
>><?xml version="1.0" encoding="utf-8" ?>
>><rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>>	xsi:noNamespaceSchemaLocation="RulesXml.xsd" >
>>	<field>
>>		<fld_name>ProjectAccount</fld_name>
>>		<fld_desc>Project ID/Account Number</fld_desc>
>>		<fld_type>C</fld_type>
>>		<fld_len>16</fld_len>
>>		<def_value></def_value>
>>		<req_entry>true</req_entry>
>>	</field>
>>	<field>
>>		<fld_name>FiscalYear</fld_name>
>>		<fld_desc>Fiscal Year</fld_desc>
>>		<fld_type>N</fld_type>
>>		<fld_len>4</fld_len>
>>		<def_value>123</def_value>
>>		<req_entry>false</req_entry>
>>	</field>
>></rules>	
>>
>>
>>Note that if I blank the tag "reg_entry" I get error.
>>
>>Let me know if you see any issues in my XML/XSD.
>>
>>Thank you.
"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