XML DataSet with Schema

M

Mark

Wow, what an unexpected hassle. I am having a really wierd and nasty problem
with an XML DataSet and the behaviour is variable according to which version
of the .NET CF you run it under, and unfortunately the bad behaviour is
under the latest version, not the oldest.

Here's the scenario:
I have an XSD and an XML that I load as follows:

Dim ds As New DataSet("My_Data")
'-----------------------------
' Read in the schema
'-----------------------------
theFile = "\Program Files\Test\My_Schema.xsd"
Dim fsXSD As New System.IO.FileStream(theFile, FileMode.Open,
FileAccess.Read)
Dim xtrXSD As New Xml.XmlTextReader(fsXSD)
ds.ReadXmlSchema(xtrXSD)

'----------------------------
' Read in the file
'----------------------------
theFile = "\Program Files\Test\My_Example.xml"
Dim fsXML As New System.IO.FileStream(theFile, FileMode.Open)
Dim xtrXML As New Xml.XmlTextReader(fsXML)
ds.ReadXml(xtrXML)

At one point in the XML file I have a set of elements like this

<Action Type="INCOME" Description="Salary 1" Amount="3500"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Annual Bonus" Amount="18000"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Salary2" Amount="4500"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Investment Income" Amount="10000"
Frequency="Yearly" Include="?" />


When this runs under .NET CF Version [1.0.3316.0], I wind up with every
second element if I load the Schema, and ALL of the elements if I don't load
the Schema. Also, If I change the elements to be <Action .... ></Action>
instead of <Action ... /> I get all of the elements loaded regardless of
whether the schema is loaded or not.

When this runs under .NET CF Version [1.0.2268.0], I wind up with every
element regardless of whether I load the Schema or not.

I can't really expect to be able to tell my users to downgrade their version
of .NET CF, now can I ;)

Anyone with a helpfull suggestion on this would clearly take on legend
status in my eyes.

Thanks for taking the time to read this.
 
G

Guest

care to post the schema

if not, are you setting minoccurs and maxoccurs of that element in it?
 
M

Mark

Schema segment
<xs:element name="Action" minOccurs="0" maxOccurs="unbounded">

<xs:complexType>

<xs:attribute name="Type" form="unqualified" type="xs:string" />

<xs:attribute name="Description" form="unqualified" type="xs:string" />

<xs:attribute name="Amount" form="unqualified" type="xs:double" />

<xs:attribute name="Frequency" form="unqualified" type="xs:string" />

<xs:attribute name="Include" form="unqualified" type="xs:string" />

</xs:complexType>



As I said, all I have to do to make it work is not use the latest version of
the Compact Framework.
 
I

Ilya Tumanov [MS]

Mark,

XML loader which uses schema was rewritten in SP2 to improve performance,
so it might be a bug introduced in the process.
Or, if your data does not match schema, it might be a known difference in
behavior.

I could not reproduce the problem, however (please see data I'm using
below).

Could you please provide complete XML and schema so I can reproduce this
problem? Thanks.

XML file:

<DataSet>
<Action Type="INCOME" Description="Salary 1" Amount="3500"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Annual Bonus" Amount="18000"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Salary2" Amount="4500"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Investment Income" Amount="10000"
Frequency="Yearly" Include="?" />
</DataSet>

Schema file:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Action">
<xs:complexType>
<xs:attribute name="Type" type="xs:string" />
<xs:attribute name="Description" type="xs:string" />
<xs:attribute name="Amount" type="xs:string" />
<xs:attribute name="Frequency" type="xs:string" />
<xs:attribute name="Include" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Data, saved from DataSet after loading was completed.

<DataSet>
<xs:schema id="DataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Action">
<xs:complexType>
<xs:attribute name="Type" type="xs:string" />
<xs:attribute name="Description" type="xs:string" />
<xs:attribute name="Amount" type="xs:string" />
<xs:attribute name="Frequency" type="xs:string" />
<xs:attribute name="Include" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Action Type="INCOME" Description="Salary 1" Amount="3500"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Annual Bonus" Amount="18000"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Salary2" Amount="4500"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Investment Income" Amount="10000"
Frequency="Yearly" Include="?" />
</DataSet>


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
M

Mark

Ilya, I can send you a whole zipped up Solution that neatly demonstrates the
problem.
Should I email it to you directly?

The scenarios are:
1. .NET CF V [1.0.2268.0] Loading data without schema, I get every row
2. .NET CF V [1.0.2268.0] Loading data with schema, I get every row
3. .NET CF V [1.0.3316.0] Loading data without schema, I get every row
4. .NET CF V [1.0.3316.0] Loading data with schema, I get every second
row

Cheers,

"Ilya Tumanov [MS]" said:
Mark,

XML loader which uses schema was rewritten in SP2 to improve performance,
so it might be a bug introduced in the process.
Or, if your data does not match schema, it might be a known difference in
behavior.

I could not reproduce the problem, however (please see data I'm using
below).

Could you please provide complete XML and schema so I can reproduce this
problem? Thanks.

XML file:

<DataSet>
<Action Type="INCOME" Description="Salary 1" Amount="3500"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Annual Bonus" Amount="18000"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Salary2" Amount="4500"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Investment Income" Amount="10000"
Frequency="Yearly" Include="?" />
</DataSet>

Schema file:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Action">
<xs:complexType>
<xs:attribute name="Type" type="xs:string" />
<xs:attribute name="Description" type="xs:string" />
<xs:attribute name="Amount" type="xs:string" />
<xs:attribute name="Frequency" type="xs:string" />
<xs:attribute name="Include" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Data, saved from DataSet after loading was completed.

<DataSet>
<xs:schema id="DataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Action">
<xs:complexType>
<xs:attribute name="Type" type="xs:string" />
<xs:attribute name="Description" type="xs:string" />
<xs:attribute name="Amount" type="xs:string" />
<xs:attribute name="Frequency" type="xs:string" />
<xs:attribute name="Include" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Action Type="INCOME" Description="Salary 1" Amount="3500"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Annual Bonus" Amount="18000"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Salary2" Amount="4500"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Investment Income" Amount="10000"
Frequency="Yearly" Include="?" />
</DataSet>


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
Subject: Re: XML DataSet with Schema
Date: Fri, 6 Feb 2004 09:10:42 +1100
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: cpe-144-132-236-149.nsw.bigpond.net.au 144.132.236.149
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.
phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.compactframework:45046
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework


Schema segment
<xs:element name="Action" minOccurs="0" maxOccurs="unbounded">

<xs:complexType>

<xs:attribute name="Type" form="unqualified" type="xs:string" />

<xs:attribute name="Description" form="unqualified" type="xs:string" />

<xs:attribute name="Amount" form="unqualified" type="xs:double" />

<xs:attribute name="Frequency" form="unqualified" type="xs:string" />

<xs:attribute name="Include" form="unqualified" type="xs:string" />

</xs:complexType>



As I said, all I have to do to make it work is not use the latest
version
of
the Compact Framework.
 
I

Ilya Tumanov [MS]

Yes, please. You'll need to remove 'online' from my email to send me a
message.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
<[email protected]>
Subject: Re: XML DataSet with Schema
Date: Fri, 6 Feb 2004 14:51:15 +1100
Lines: 163
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#jHD#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: cpe-144-132-236-149.nsw.bigpond.net.au 144.132.236.149
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.
phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.compactframework:45071
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Ilya, I can send you a whole zipped up Solution that neatly demonstrates the
problem.
Should I email it to you directly?

The scenarios are:
1. .NET CF V [1.0.2268.0] Loading data without schema, I get every row
2. .NET CF V [1.0.2268.0] Loading data with schema, I get every row
3. .NET CF V [1.0.3316.0] Loading data without schema, I get every row
4. .NET CF V [1.0.3316.0] Loading data with schema, I get every second
row

Cheers,

"Ilya Tumanov [MS]" said:
Mark,

XML loader which uses schema was rewritten in SP2 to improve performance,
so it might be a bug introduced in the process.
Or, if your data does not match schema, it might be a known difference in
behavior.

I could not reproduce the problem, however (please see data I'm using
below).

Could you please provide complete XML and schema so I can reproduce this
problem? Thanks.

XML file:

<DataSet>
<Action Type="INCOME" Description="Salary 1" Amount="3500"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Annual Bonus" Amount="18000"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Salary2" Amount="4500"
Frequency="Monthly" Include="?"/>
<Action Type="INCOME" Description="Investment Income" Amount="10000"
Frequency="Yearly" Include="?" />
</DataSet>

Schema file:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Action">
<xs:complexType>
<xs:attribute name="Type" type="xs:string" />
<xs:attribute name="Description" type="xs:string" />
<xs:attribute name="Amount" type="xs:string" />
<xs:attribute name="Frequency" type="xs:string" />
<xs:attribute name="Include" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Data, saved from DataSet after loading was completed.

<DataSet>
<xs:schema id="DataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Action">
<xs:complexType>
<xs:attribute name="Type" type="xs:string" />
<xs:attribute name="Description" type="xs:string" />
<xs:attribute name="Amount" type="xs:string" />
<xs:attribute name="Frequency" type="xs:string" />
<xs:attribute name="Include" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Action Type="INCOME" Description="Salary 1" Amount="3500"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Annual Bonus" Amount="18000"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Salary2" Amount="4500"
Frequency="Monthly" Include="?" />
<Action Type="INCOME" Description="Investment Income" Amount="10000"
Frequency="Yearly" Include="?" />
</DataSet>


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
Subject: Re: XML DataSet with Schema
Date: Fri, 6 Feb 2004 09:10:42 +1100
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: cpe-144-132-236-149.nsw.bigpond.net.au 144.132.236.149
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top