G
Guest
Hi all,
I use a typed dataset in my applicaiton. There are three levels defined in
the .xsd, first level is member, which has child element named plan, which
has child element named fund. The structure looks like:
<xs:element name="mem">
<xs:complexType>
<xs:sequence>
<xs:element name="plan" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:element name="fund" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="fund_key" form="unqualified"
type="xs:string" />
<xs:attribute name="plan_key" form="unqualified"
type="xs:string" />
<xs:attribute name="fund_value" form="unqualified"
type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="plan_key" form="unqualified" type="xs:string" />
<xs:attribute name="mem_key" form="unqualified" type="xs:string" />
<xs:attribute name="plan_name" form="unqualified" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="mem_key" form="unqualified" type="xs:string" />
<xs:attribute name="mem_name" form="unqualified" type="xs:string" />
</xs:complexType>
<xs:key name="memKey1">
<xs:selector xpath="." />
<xs:field xpath="@mem_key" />
</xs:key>
<xs:keyref name="mem_plan" refer="memKey1">
<xs:selector xpath=".//mstns:mem_plan" />
<xs:field xpath="@mem_key" />
</xs:keyref>
<xs:key name="memKey2">
<xs:selector xpath=".//mstns:mem_plan" />
<xs:field xpath="@plan_key" />
</xs:key>
<xs:keyref name="plan_fund" refer="memKey2">
<xs:selector xpath=".//mstnslan_fund" />
<xs:field xpath="@plan_key" />
</xs:keyref>
</xs:element>
I also defined nested relationship. But when I get xml from the dataset, the
file is flat format instead nested.
For example, I have a member, who has 2 plans, each plan has 2 funds. I want
to get a xml file like:
<mem1 mem_key=1 mem_name=john >
<plan1 plan_key=1 mem_key=1 plan_name=ESP>
<fund1 fund_key=1 plan_key=1 fund_value=20 />
<fund2 fund_key=2 plan_key=1 fund_value=30 />
</plan1>
<plan2 plan_key=2 mem_key=1 plan_name=RRSP>
<fund3 fund_key=3 plan_key=2 fund_value=20 />
<fund4 fund_key=4 plan_key=2 fund_value=30 />
</plan2>
</mem1>
But what I got is:
<mem1 mem_key=1 mem_name=john />
<plan1 plan_key=1 mem_key=1 plan_name=ESP/>
<plan2 plan_key=2 mem_key=1 plan_name=RRSP/>
<fund1 fund_key=1 plan_key=1 fund_value=20 />
<fund2 fund_key=2 plan_key=1 fund_value=30 />
<fund3 fund_key=3 plan_key=2 fund_value=20 />
<fund4 fund_key=4 plan_key=2 fund_value=30 />
Could anyone give me a sample code to fix it?
Thanks in advance.
william
I use a typed dataset in my applicaiton. There are three levels defined in
the .xsd, first level is member, which has child element named plan, which
has child element named fund. The structure looks like:
<xs:element name="mem">
<xs:complexType>
<xs:sequence>
<xs:element name="plan" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:element name="fund" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="fund_key" form="unqualified"
type="xs:string" />
<xs:attribute name="plan_key" form="unqualified"
type="xs:string" />
<xs:attribute name="fund_value" form="unqualified"
type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="plan_key" form="unqualified" type="xs:string" />
<xs:attribute name="mem_key" form="unqualified" type="xs:string" />
<xs:attribute name="plan_name" form="unqualified" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="mem_key" form="unqualified" type="xs:string" />
<xs:attribute name="mem_name" form="unqualified" type="xs:string" />
</xs:complexType>
<xs:key name="memKey1">
<xs:selector xpath="." />
<xs:field xpath="@mem_key" />
</xs:key>
<xs:keyref name="mem_plan" refer="memKey1">
<xs:selector xpath=".//mstns:mem_plan" />
<xs:field xpath="@mem_key" />
</xs:keyref>
<xs:key name="memKey2">
<xs:selector xpath=".//mstns:mem_plan" />
<xs:field xpath="@plan_key" />
</xs:key>
<xs:keyref name="plan_fund" refer="memKey2">
<xs:selector xpath=".//mstnslan_fund" />
<xs:field xpath="@plan_key" />
</xs:keyref>
</xs:element>
I also defined nested relationship. But when I get xml from the dataset, the
file is flat format instead nested.
For example, I have a member, who has 2 plans, each plan has 2 funds. I want
to get a xml file like:
<mem1 mem_key=1 mem_name=john >
<plan1 plan_key=1 mem_key=1 plan_name=ESP>
<fund1 fund_key=1 plan_key=1 fund_value=20 />
<fund2 fund_key=2 plan_key=1 fund_value=30 />
</plan1>
<plan2 plan_key=2 mem_key=1 plan_name=RRSP>
<fund3 fund_key=3 plan_key=2 fund_value=20 />
<fund4 fund_key=4 plan_key=2 fund_value=30 />
</plan2>
</mem1>
But what I got is:
<mem1 mem_key=1 mem_name=john />
<plan1 plan_key=1 mem_key=1 plan_name=ESP/>
<plan2 plan_key=2 mem_key=1 plan_name=RRSP/>
<fund1 fund_key=1 plan_key=1 fund_value=20 />
<fund2 fund_key=2 plan_key=1 fund_value=30 />
<fund3 fund_key=3 plan_key=2 fund_value=20 />
<fund4 fund_key=4 plan_key=2 fund_value=30 />
Could anyone give me a sample code to fix it?
Thanks in advance.
william