Retrieve info from Dataset with Relations (Dataset,SQL or XML)

J

Joe

Hi

I am going to receive a dataset downstream and I will not know the
the fields
number of field
relations
number of relations

So I have to be flexible to take unknown data and be able to summarize all
the info being passed
I have included an example

I don't know what is the best way to attack this

XML and Xpath using the XSD as a guide?? I am not too familiar with what the
xsd is giving me
If I know how many tables and what field to xpath to the different levels
???

Dataset and walk the relations?? But they are at different levels
Every row get another row collection with the GetChild depending on the
number of relations
They cascade or are nested

What I want to see is


GM Pontiac GTO 82 4
GM Pontiac Gand Prix 134 38
GM Pontiac 1130 630
....
....

GM Buick 294 84
GM 43310 9880




<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<l1>
<ID>Total</ID>
<Company>GM</Company>
<Sum_x0020_of_x0020_HoursDev>43310</Sum_x0020_of_x0020_HoursDev>
<Sum_x0020_of_x0020_MarketLife>9880</Sum_x0020_of_x0020_MarketLife>
</l1>
<l2>
<ID>Total</ID>
<Company>GM</Company>
<Division>Pontiac</Division>
<Sum_x0020_of_x0020_HoursDev>1130</Sum_x0020_of_x0020_HoursDev>
<Sum_x0020_of_x0020_MarketLife>630</Sum_x0020_of_x0020_MarketLife>
</l2>
<l2>
<ID>Total</ID>
<Company>GM</Company>
<Division>Buick</Division>
<Sum_x0020_of_x0020_HoursDev>294</Sum_x0020_of_x0020_HoursDev>
<Sum_x0020_of_x0020_MarketLife>84</Sum_x0020_of_x0020_MarketLife>
</l2>
<l2>
<ID>Total</ID>
<Company>GM</Company>
<Division>Cadillac</Division>
<Sum_x0020_of_x0020_HoursDev>5658</Sum_x0020_of_x0020_HoursDev>
<Sum_x0020_of_x0020_MarketLife>2038</Sum_x0020_of_x0020_MarketLife>
</l2>
<l3>
<ID>Total</ID>
<Company>GM</Company>
<Division>Pontiac</Division>
<Car>GTO</Car>
<Sum_x0020_of_x0020_HoursDev>82</Sum_x0020_of_x0020_HoursDev>
<Sum_x0020_of_x0020_MarketLife>4</Sum_x0020_of_x0020_MarketLife>
</l3>
<l3>
<ID>Total</ID>
<Company>GM</Company>
<Division>Pontiac</Division>
<Car>Grand Prix</Car>
<Sum_x0020_of_x0020_HoursDev>134</Sum_x0020_of_x0020_HoursDev>
<Sum_x0020_of_x0020_MarketLife>38</Sum_x0020_of_x0020_MarketLife>
</l3>
<NewDataSet>



<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="vDWHPat">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:string" minOccurs="0" />
<xs:element name="Sum_x0020_of_x0020_HoursDev"
type="xs:double" minOccurs="0" />
<xs:element name="Sum_x0020_of_x0020_MarketLife"
type="xs:double" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="l1">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:string" minOccurs="0" />
<xs:element name="Company" type="xs:string" minOccurs="0" />
<xs:element name="Sum_x0020_of_x0020_HoursDev"
type="xs:double" minOccurs="0" />
<xs:element name="Sum_x0020_of_x0020_MarketLife"
type="xs:double" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="l2">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:string" minOccurs="0" />
<xs:element name="Company" type="xs:string" minOccurs="0" />
<xs:element name="Division" type="xs:string" minOccurs="0" />
<xs:element name="Sum_x0020_of_x0020_HoursDev"
type="xs:double" minOccurs="0" />
<xs:element name="Sum_x0020_of_x0020_MarketLife"
type="xs:double" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="l3">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:string" minOccurs="0" />
<xs:element name="Company" type="xs:string" minOccurs="0" />
<xs:element name="Division" type="xs:string" minOccurs="0" />
<xs:element name="MainDepartment" type="xs:string"
minOccurs="0" />
<xs:element name="Sum_x0020_of_x0020_HoursDev"
type="xs:double" minOccurs="0" />
<xs:element name="Sum_x0020_of_x0020_MarketLife"
type="xs:double" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//Table" />
<xs:field xpath="ID" />
</xs:unique>
<xs:unique name="l1_Constraint1" msdata:ConstraintName="Constraint1">
<xs:selector xpath=".//l1" />
<xs:field xpath="ID" />
<xs:field xpath="Company" />
</xs:unique>
<xs:unique name="l2_Constraint1" msdata:ConstraintName="Constraint1">
<xs:selector xpath=".//l2" />
<xs:field xpath="ID" />
<xs:field xpath="Company" />
<xs:field xpath="Division" />
</xs:unique>
<xs:keyref name="l2" refer="l2_Constraint1">
<xs:selector xpath=".//l3" />
<xs:field xpath="ID" />
<xs:field xpath="Company" />
<xs:field xpath="Division" />
</xs:keyref>
<xs:keyref name="l1" refer="l1_Constraint1">
<xs:selector xpath=".//l2" />
<xs:field xpath="ID" />
<xs:field xpath="Company" />
</xs:keyref>
<xs:keyref name="l0" refer="Constraint1">
<xs:selector xpath=".//l1" />
<xs:field xpath="ID" />
</xs:keyref>
</xs:element>
</xs:schema>
 
N

Nicholas Paldino [.NET/C# MVP]

Joe,

I definitely would not use XML/XPath for this. I would just cycle
through all of the relations on each row as you cycle through the tables.
It's just a few calls in a loop as you iterate through the rows.

Hope this helps.
 
N

Nicholas Paldino [.NET/C# MVP]

Joe,

I definitely would not use XML/XPath for this. I would just cycle
through all of the relations for each row as you cycle through the tables.
It's just a few calls in a loop as you iterate through the rows.

Hope this helps.
 

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