XML Stage to convert child repeating elements into rows

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
partha.natta
Premium Member
Premium Member
Posts: 32
Joined: Tue Mar 09, 2010 5:56 am
Location: Bangalore

XML Stage to convert child repeating elements into rows

Post by partha.natta »

Hi All,

Below its a sample transaction record that I am trying to process in XML stage.
There can be multiple TransferFund under one traansaction, when more than one TransferFund are coming then the detila inside the trasnfer fund should come in a new row with the Parent Tag Values.

Could you please lert me know how to solve this issue.

<TrxnRec><ProcessDate>20140702</ProcessDate>
<FundAcctID>26204388</FundAcctID>
<AcctDesig>1</AcctDesig>
<DlrCode>9190</DlrCode>
<DlrAcctID>543080691</DlrAcctID>
<RepCode>AAA</RepCode>
<AcctType>01</AcctType>
<OrdSrc>D</OrdSrc>
<OrdType>D</OrdType>
<SrcID>ETCOF0262043889</SrcID>
<ETCof>
<TrxnTyp>5</TrxnTyp>
<TrxnTypDtl>4</TrxnTypDtl>
<FromAcct>
<FundAcctID>26204388</FundAcctID>
<DlrCode>7568</DlrCode>
<DlrAcctID>543080691</DlrAcctID>
<AcctDesig>1</AcctDesig>
<AcctType>01</AcctType>
</FromAcct>
<TrnsfrFund>
<FundID>266</FundID>
<GrossAmt>0.00</GrossAmt>
<UnitTrxnd>0.0000</UnitTrxnd>
<AveCost>0.0000</AveCost>
</TrnsfrFund>
<TrnsfrFund>
<FundID>568</FundID>
<GrossAmt>21180.08</GrossAmt>
<UnitTrxnd>1650.7480</UnitTrxnd>
<AveCost>0.0000</AveCost>
</TrnsfrFund>
<TrnsfrFund>
<FundID>590</FundID>
<GrossAmt>11394.67</GrossAmt>
<UnitTrxnd>574.8760</UnitTrxnd>
<AveCost>0.0000</AveCost>
</TrnsfrFund>
<TrnsfrFund>
<FundID>702</FundID>
<GrossAmt>26314.79</GrossAmt>
<UnitTrxnd>1326.8990</UnitTrxnd>
<AveCost>0.0000</AveCost>
</TrnsfrFund>
<TradeDate>20140702</TradeDate>
<SettlDate>20140702</SettlDate>
<Demo>
</Demo>
</ETCof>
</TrxnRec>
</TrxnRecon>
Last edited by partha.natta on Fri Jul 11, 2014 2:24 pm, edited 2 times in total.
Thanks & Regards,
Partha
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

How about you describe to us what the actual issue is? What is it that you are trying to accomplish? For example are you looking to read or to generate XML of this kind?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
partha.natta
Premium Member
Premium Member
Posts: 32
Joined: Tue Mar 09, 2010 5:56 am
Location: Bangalore

Post by partha.natta »

Hi Ray,

Thanks for your response. Yes, I am trying to read this type of XML file and want to create multiple rows based on the number of TransferFund sections coming in the XML file.
Thanks & Regards,
Partha
MT
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 09, 2007 3:51 am

Post by MT »

Hi partha.natta


use the Parser step within the XML stage.
The PARSER defines how the XML looks like
and in the OUTPUT step you defines how many rows will be created.
regards

Michael
partha.natta
Premium Member
Premium Member
Posts: 32
Joined: Tue Mar 09, 2010 5:56 am
Location: Bangalore

Post by partha.natta »

Hi Michael,

I am doing the same steps in my job, and but I am getting only the first TransfrID values(FundID,GrossAmt,UnitTrxnd,AveCost) coming in output.For the other TransferID details should come in a different row in same column (FundID,GrossAmt,UnitTrxnd and AveCost) with the parent values i.e. extra new row need to be created.
Thanks & Regards,
Partha
partha.natta
Premium Member
Premium Member
Posts: 32
Joined: Tue Mar 09, 2010 5:56 am
Location: Bangalore

Post by partha.natta »

The output result should come like this.

Expected Result:

ProcessDate|FundAcctID|DlrAcctID|RepCode|FundID|GrossAmt|UnitTrxnd|AveCost
20140702|26204388|543080691|AAA|266|0|0|0
20140702|26204388|543080691|AAA|568|21180.08|1650.748|0
20140702|26204388|543080691|AAA|590|11394.67|574.876|0
20140702|26204388|543080691|AAA|702|26314.79|1326.899|0

But currently I am getting only the first record.
Thanks & Regards,
Partha
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

That often indicates that you either mapped to the wrong list, or that your "list" isn't correctly defined. Be sure that in your xsd, the node that you want multiple rows has a proper "maxOccurs=unbounded" or some number greater than 1.

It must be formally stated...the default for xsd's is maxOccurs=1.....

The xml Stage obeys the xsd standard.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
partha.natta
Premium Member
Premium Member
Posts: 32
Joined: Tue Mar 09, 2010 5:56 am
Location: Bangalore

Post by partha.natta »

Hi Ernie,

Thanks for your response.

This way it is mentioned in XSD.

<xsd:element name="ETCof">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="TrxnTyp"/>
<xsd:element ref="TrxnTypDtl"/>
<xsd:element ref="CntbWdCode" minOccurs="0"/>
<xsd:element ref="OrdFundID" minOccurs="0"/>
<xsd:choice>
<xsd:element ref="ToAcct"/>
<xsd:element ref="FromAcct"/>
</xsd:choice>
<xsd:choice maxOccurs="unbounded">
<xsd:element ref="TrnsfrAAFund"/>
<xsd:element ref="TrnsfrFund"/>
</xsd:choice>
<xsd:element ref="TaxEvnt" minOccurs="0"/>
<xsd:element ref="OrigNtwrk" minOccurs="0"/>
<xsd:element ref="TradeDate"/>
<xsd:element ref="SettlDate"/>
<xsd:element ref="Demo" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Thanks & Regards,
Partha
Post Reply