HighTechTalks DotNet Forums  

Schema-Typed Dataset doesn't preserve nested tables order

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss Schema-Typed Dataset doesn't preserve nested tables order in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
sunstormlabs@gmail.com
 
Posts: n/a

Default Schema-Typed Dataset doesn't preserve nested tables order - 12-16-2007 , 09:47 PM






Hello,

I'm having trouble with schema-bound XML output from a dataset,
in .NET 2.0. Here's an example bit of XML I'm trying to create using a
dataset:

<TestSchema xmlns="http://tempuri.org/TestSchema.xsd">
<Customer>
<Name>Mr. Foo</Name>
<Company>Foo Inc.</Company>
<BillingAddress>
<BuildingNumber>123</BuildingNumber>
<StreetName>Street Name</StreetName>
<City>City</City>
</BillingAddress>
<Telephone>123456789</Telephone>
</Customer>
</TestSchema>

Note that BillingAddress goes before Telephone.

I'm using the following schema, which I have no control over, and so
can't change, to generate the dataset using VS2008's dataset
generator:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="TestSchema" targetNamespace="http://tempuri.org/
TestSchema.xsd" elementFormDefault="qualified" xmlns="http://
tempuri.org/TestSchema.xsd" xmlns:mstns="http://tempuri.org/
TestSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name='Name' type='xs:string' />
<xs:element name='Company' type='xs:string' />
<xs:element name='Telephone' type='xs:string' />

<xs:element name='BuildingNumber' type='xs:string' />
<xs:element name='City' type='xs:string' />
<xs:element name='StreetName' type='xs:string' />

<xs:complexType name='AddressStructure'>
<xs:sequence>
<xs:element ref='BuildingNumber' minOccurs='0' />
<xs:element ref='StreetName' minOccurs='0' />
<xs:element ref='City' />
</xs:sequence>
</xs:complexType>

<xs:element name='BillingAddress' type='AddressStructure' />

<xs:element name='Customer'>
<xs:complexType>
<xs:sequence>
<xs:element ref='Name' />
<xs:element ref='Company' />
<xs:element ref='BillingAddress' />
<xs:element ref='Telephone' />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

It works just fine, the dataset generator creates the keys and
relationships to nest the BillingAddress table, and I can fill in the
data I need into the dataset like so...

TestSchema set = new TestSchema();
TestSchema.CustomerRow customerRow =
set.Customer.AddCustomerRow( "Mr.Foo", "Foo Inc.", "123456789" );
set.BillingAddress.AddBillingAddressRow( "123", "Street Name", "City",
customerRow );

However, the output I get is...

<TestSchema xmlns="http://tempuri.org/TestSchema.xsd">
<Customer>
<Name>Mr.Foo</Name>
<Company>Foo Inc.</Company>
<Telephone>123456789</Telephone>
<BillingAddress>
<BuildingNumber>123</BuildingNumber>
<StreetName>Street Name</StreetName>
<City>City</City>
</BillingAddress>
</Customer>
</TestSchema>

Note how BillingAddress has moved to the end, effectively making the
XML non-compliant to the schema. I can't see any reason why would the
dataset willingly break it's own schema.

Any idea how to get around this strange behavior?

Reply With Quote
  #2  
Old   
varsha.dhankani@gmail.com
 
Posts: n/a

Default Re: Schema-Typed Dataset doesn't preserve nested tables order - 12-18-2007 , 04:47 AM






Hey

Did you find a solution to the above problem?
I'm stuck with the same..

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.