PC Review


Reply
Thread Tools Rate Thread

XML schema qustion

 
 
Chris Capel
Guest
Posts: n/a
 
      3rd Feb 2004
I have an xml schema, and one one of the attributes on one of my elements, I
do this:

<xs:element name="class">
<xs:complexType>
<xs:attribute name="hasCollection" type="xs:boolean" default="true" />
</xs:complexType>
</xs:element>

Notice that the default value of the hasCollection attribute is "true".
However, when I read in my xml file (which is validated fine) using this
code:

DataSet ds;
ds.ReadXmlSchema("StructDefinition.xsd");
ds.ReadXml(inputFile);

and then check the value of "hasCollection" on a DataRow that's set to a row
of the "class" element using this code:

DataRow @class;
if ((bool)@class["hasCollection"])
DoSomething();

I quickly find that the value of @class["hasCollection"] is DBNull.Value,
instead of true, when the hasCollection attribute isn't set. Is there
something I'm doing wrong?


 
Reply With Quote
 
 
 
 
Chris Capel
Guest
Posts: n/a
 
      3rd Feb 2004
No one knows? If I'm not doing something wrong, I'd be confident in saying
that this is a bug in the XML parser in the framework.

"Chris Capel" <(E-Mail Removed)> wrote in message
news:Omdyl%(E-Mail Removed)...
> I have an xml schema, and one one of the attributes on one of my elements,

I
> do this:
>
> <xs:element name="class">
> <xs:complexType>
> <xs:attribute name="hasCollection" type="xs:boolean" default="true" />
> </xs:complexType>
> </xs:element>
>
> Notice that the default value of the hasCollection attribute is "true".
> However, when I read in my xml file (which is validated fine) using this
> code:
>
> DataSet ds;
> ds.ReadXmlSchema("StructDefinition.xsd");
> ds.ReadXml(inputFile);
>
> and then check the value of "hasCollection" on a DataRow that's set to a

row
> of the "class" element using this code:
>
> DataRow @class;
> if ((bool)@class["hasCollection"])
> DoSomething();
>
> I quickly find that the value of @class["hasCollection"] is DBNull.Value,
> instead of true, when the hasCollection attribute isn't set. Is there
> something I'm doing wrong?
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I sync a typed dataset schema with database schema easily? John Microsoft Dot NET 1 2nd Jan 2008 11:37 AM
can't create schema using .adp (or transfertext method renderred useless without schema) kreplech@gmail.com Microsoft Access 1 23rd Jun 2006 10:49 PM
DataSet ReadXmlSchema fails on a schema with (xsd:)imported schema Eric van Wijk Microsoft ADO .NET 0 27th Jul 2004 06:14 PM
qustion ahmed Windows XP General 1 30th Sep 2003 04:08 AM
qustion C. J. Windows XP General 3 2nd Aug 2003 09:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:18 PM.