XML schema qustion

  • Thread starter Thread starter Chris Capel
  • Start date Start date
C

Chris Capel

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?
 
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.
 
Back
Top