G
Guest
Hi,
I have aproblem with nesting of tables in an schema generated dataset,
What I am trying to do is nest delivery item data in a delivery table, then
out put the data to a xml file. When I do this, what should be nested xml
elements I end up getting the opposite.
An example of the code I'm using is:
DataRow newSale = this.dataset.Tables["sale"].NewRow ();
DataRow newItem = this.dataset.Relations["sale_to_item"].ChildTable.NewRow ();
..
..Add data to the appropiate columns
..
this.dataset.Tables["sale"].Rows.Add ( newSale );
this.datset.Relations["sale_to_item"].ChildTable.Rows.Add ( newItem );
this.dataset.AcceptChanges ();
Below is a sample of the XML Schemas I'm using and the code
<?xml version="1.0" ?>
<xs:schema id="PDA_PROFSALE"
targetNamespace="http://tempuri.org/PDA_PROFSALE.xsd"
xmlns:mstns="http://tempuri.org/PDA_PROFSALE.xsd"
xmlns="http://tempuri.org/PDA_PROFSALE.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="PDA_PROFSALE" msdata:IsDataSet="true"
msdata:Locale="en-AU" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="sale" msdata:CaseSensitive="false" minOccurs="1"
maxOccurs="1000000" form="qualified">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="0"
msdata:AutoIncrement="true" msdata:AutoIncrementSeed="0"
msdata:AutoIncrementStep="1" msdata:ReadOnly="true" />
<xs:element name="co_last_name" type="xs:string" minOccurs="0" />
<xs:element name="first_name" type="xs:string" minOccurs="0" />
<xs:element name="details_date" type="xs:string" minOccurs="0" />
<xs:element name="non_GST_amount" type="xs:string" minOccurs="0" />
<xs:element name="salesperson" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="sale_ID" type="xs:int" minOccurs="0" />
<xs:element name="salesperson_last_name" type="xs:string"
minOccurs="0" />
<xs:element name="salesperson_first_name" type="xs:string"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="item" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="sale_ID" type="xs:int" minOccurs="0" />
<xs:element name="item_quantity" type="xs:string" minOccurs="0" />
<xs:element name="item_size" type="xs:string" minOccurs="0" />
<xs:element name="item_type" type="xs:string" minOccurs="0" />
<xs:element name="item_charge" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="other">
<xs:complexType>
<xs:sequence>
<xs:element name="last_name" type="xs:string" minOccurs="0" />
<xs:element name="given_name" type="xs:string" minOccurs="0" />
<xs:element name="sale_ID" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="PDA_PROFSALEKey1" msdatarimaryKey="true">
<xs:selector xpath=".//mstns:sale" />
<xs:field xpath="mstns:ID" />
</xs:key>
<xs:keyref name="sale_to_salesperson" refer="mstnsDA_PROFSALEKey1">
<xs:selector xpath=".//mstns:salesperson" />
<xs:field xpath="mstns:sale_ID" />
</xs:keyref>
<xs:keyref name="sale_to_item" refer="mstnsDA_PROFSALEKey1">
<xs:selector xpath=".//mstns:item" />
<xs:field xpath="mstns:sale_ID" />
</xs:keyref>
<xs:keyref name="sale_to_other" refer="mstnsDA_PROFSALEKey1">
<xs:selector xpath=".//mstnsther" />
<xs:field xpath="mstns:sale_ID" />
</xs:keyref>
<xs:key name="PDA_PROFSALEKey2">
<xs:selector xpath=".//mstns:salesperson" />
<xs:field xpath="mstns:sale_ID" />
</xs:key>
<xs:key name="PDA_PROFSALEKey3">
<xs:selector xpath=".//mstns:item" />
<xs:field xpath="mstns:sale_ID" />
</xs:key>
<xs:key name="PDA_PROFSALEKey4">
<xs:selector xpath=".//mstnsther" />
<xs:field xpath="mstns:sale_ID" />
</xs:key>
</xs:element>
</xs:schema>
I have aproblem with nesting of tables in an schema generated dataset,
What I am trying to do is nest delivery item data in a delivery table, then
out put the data to a xml file. When I do this, what should be nested xml
elements I end up getting the opposite.
An example of the code I'm using is:
DataRow newSale = this.dataset.Tables["sale"].NewRow ();
DataRow newItem = this.dataset.Relations["sale_to_item"].ChildTable.NewRow ();
..
..Add data to the appropiate columns
..
this.dataset.Tables["sale"].Rows.Add ( newSale );
this.datset.Relations["sale_to_item"].ChildTable.Rows.Add ( newItem );
this.dataset.AcceptChanges ();
Below is a sample of the XML Schemas I'm using and the code
<?xml version="1.0" ?>
<xs:schema id="PDA_PROFSALE"
targetNamespace="http://tempuri.org/PDA_PROFSALE.xsd"
xmlns:mstns="http://tempuri.org/PDA_PROFSALE.xsd"
xmlns="http://tempuri.org/PDA_PROFSALE.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="PDA_PROFSALE" msdata:IsDataSet="true"
msdata:Locale="en-AU" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="sale" msdata:CaseSensitive="false" minOccurs="1"
maxOccurs="1000000" form="qualified">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="0"
msdata:AutoIncrement="true" msdata:AutoIncrementSeed="0"
msdata:AutoIncrementStep="1" msdata:ReadOnly="true" />
<xs:element name="co_last_name" type="xs:string" minOccurs="0" />
<xs:element name="first_name" type="xs:string" minOccurs="0" />
<xs:element name="details_date" type="xs:string" minOccurs="0" />
<xs:element name="non_GST_amount" type="xs:string" minOccurs="0" />
<xs:element name="salesperson" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="sale_ID" type="xs:int" minOccurs="0" />
<xs:element name="salesperson_last_name" type="xs:string"
minOccurs="0" />
<xs:element name="salesperson_first_name" type="xs:string"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="item" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="sale_ID" type="xs:int" minOccurs="0" />
<xs:element name="item_quantity" type="xs:string" minOccurs="0" />
<xs:element name="item_size" type="xs:string" minOccurs="0" />
<xs:element name="item_type" type="xs:string" minOccurs="0" />
<xs:element name="item_charge" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="other">
<xs:complexType>
<xs:sequence>
<xs:element name="last_name" type="xs:string" minOccurs="0" />
<xs:element name="given_name" type="xs:string" minOccurs="0" />
<xs:element name="sale_ID" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="PDA_PROFSALEKey1" msdatarimaryKey="true">
<xs:selector xpath=".//mstns:sale" />
<xs:field xpath="mstns:ID" />
</xs:key>
<xs:keyref name="sale_to_salesperson" refer="mstnsDA_PROFSALEKey1">
<xs:selector xpath=".//mstns:salesperson" />
<xs:field xpath="mstns:sale_ID" />
</xs:keyref>
<xs:keyref name="sale_to_item" refer="mstnsDA_PROFSALEKey1">
<xs:selector xpath=".//mstns:item" />
<xs:field xpath="mstns:sale_ID" />
</xs:keyref>
<xs:keyref name="sale_to_other" refer="mstnsDA_PROFSALEKey1">
<xs:selector xpath=".//mstnsther" />
<xs:field xpath="mstns:sale_ID" />
</xs:keyref>
<xs:key name="PDA_PROFSALEKey2">
<xs:selector xpath=".//mstns:salesperson" />
<xs:field xpath="mstns:sale_ID" />
</xs:key>
<xs:key name="PDA_PROFSALEKey3">
<xs:selector xpath=".//mstns:item" />
<xs:field xpath="mstns:sale_ID" />
</xs:key>
<xs:key name="PDA_PROFSALEKey4">
<xs:selector xpath=".//mstnsther" />
<xs:field xpath="mstns:sale_ID" />
</xs:key>
</xs:element>
</xs:schema>