XML File with Different tag at same level

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
pksahu
Participant
Posts: 29
Joined: Wed Jul 25, 2007 5:07 am

XML File with Different tag at same level

Post by pksahu »

Hi,
I have one xml file with Header and Trailer at the same level. The Detail records below the header maintain parent-child relationship.

Can anyone please guide me how to read and establish the parent-child relationship between those records. As the from date and tdate of the below file gets different for the same company code, I am not able to co-relate the records.

The <ZCOMMHDR> is the header tag and all <ZCOMMDET> is the detail record for that header.
The example of such file is as below:
<?xml version="1.0" encoding="utf-8"?>
<ZCOMMIT01 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<IDOC>
<ZCOMMHDR>
<ZCOMPANY>8442</ZCOMPANY>
<ZDCSITE>8442</ZDCSITE>
<ZSEASON>SM09</ZSEASON>
<ZFROMDATE>20090418</ZFROMDATE>
<ZTODATE>20090801</ZTODATE>
</ZCOMMHDR>
<ZCOMMDET>
<ZCOMPANY>8442</ZCOMPANY>
<ZARTICLE>T16 9076AY0 0500</ZARTICLE>
<ZCOMMIT_QTY>90</ZCOMMIT_QTY>
<ZBUILD_QTY>900</ZBUILD_QTY>
<ZEIP>28.80</ZEIP>
<ZCOMMIT_UNIT>EA</ZCOMMIT_UNIT>
</ZCOMMDET>
<ZCOMMDET>
<ZCOMPANY>8442</ZCOMPANY>
<ZARTICLE>T16 9075AT0 0100</ZARTICLE>
<ZCOMMIT_QTY>142</ZCOMMIT_QTY>
<ZBUILD_QTY>1421</ZBUILD_QTY>
<ZEIP>30.10</ZEIP>
<ZCOMMIT_UNIT>EA</ZCOMMIT_UNIT>
</ZCOMMDET>
<ZCOMPANY>9328</ZCOMPANY>
<ZDCSITE>9328</ZDCSITE>
<ZSEASON>SM09</ZSEASON>
<ZFROMDATE>20090509</ZFROMDATE>
<ZTODATE>20090822</ZTODATE>
</ZCOMMHDR>
<ZCOMMDET>
<ZCOMPANY>9328</ZCOMPANY>
<ZARTICLE>T41 2508 YZ 0600</ZARTICLE>
<ZCOMMIT_QTY>1400</ZCOMMIT_QTY>
<ZBUILD_QTY>14000</ZBUILD_QTY>
<ZEIP>3.65</ZEIP>
<ZCOMMIT_UNIT>EA</ZCOMMIT_UNIT>
</ZCOMMDET>
</IDOC>
</ZCOMMIT01>

Regards,
Pksahu
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Is this the actual source? It seems that one of the tags is missing for the opening of the next-to-last ZCOMMDET element. I'll assume for the moment that the issue for that is just a typo or cut/paste issue into the forum.

As for the hierarchy, it actually looks fairly normal....it's just a straight path, from what I can see....... /ZCOMMIT01/IDOC/ZCOMMHDR and its detail, which "probably" occurs only once, and then the /ZCOMMIT01/IDOC/ZCOMMDET elements, which occur multiple times. Describing all the colums in one link, and having one of them at the ZCOMMDET as the repeating element (perhaps ZCOMPANY) should get you what you want. Did you use the XMLimporter on this instance? What errors are you getting?

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

Look spretty normal, read the tags differntly and parse the data out, lookup and join..You may require a external command to spit out the XML to XML input stage..and take the 2 tags to different outputs and join data based on the company ID ( ZCOMPANY)
Post Reply