Repeating xml files

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
jagadam
Premium Member
Premium Member
Posts: 107
Joined: Wed Jul 01, 2009 4:55 pm
Location: Phili

Repeating xml files

Post by jagadam »

Hi All,

we have a requirement where we need to build an xml based on a certain logic which is based on the input data file.

Input data file:

Feild1 Field2 Field3
1 2238681 AA

1 2566855 AA

1 3321605 AA

2 3049616 11

2 3321609 11

2 3321616 11

2 3321610 11


Business Logic:

If the field1 value= 1 then fill out Main Part of XML

If the field1 value= 2 then fill out the PACS Tab for the previous part where field1 value= 1. There can be multiple value 2s for each value 1 or none at all.


Sample xml:

<Vacant_Per_Sales>
<Vacant_Per_Rec>
<Pro>1234</Pro>
<Pro_Li>Vacant Part</Pro_Li>
<Header_Attribute>
<Name>Pri For Typ</Name>
</Header_Attribute>
<Header_Attribute>
<Name>Act Code</Name>
</Header_Attribute>
<Cate>
<Cate_Name>PACS</Cate_Name>
<Cate_Itm>
<Itm_Na>003</Itm_Na>
<Group_Name/>
<Is_Default>X</Is_Default>
<Pri/>
<Item_Attribute>
<Name>abc</Name>
</Item_Attribute>
<Item_Attribute>
<Name>edf</Name>
</Item_Attribute>
</Cate_Itm>
</Cate>
</Vacant_Per_Rec>
</Vacant_Per_Sales>


Explanation of the business logic:
If the field1 value=1 then we need to pass the values to xml excluding the Cate_Name "PACS" in the xml.But if we have the field1 value=2 then row values corresponding to the value 2 should be passed on to the "PACS" inlcuding the previous value=1 i.e the whole xml above should be sent out.
There can be multiple value 2's following the value 1 then the "PACS" part of xml should repeat for each value=1.

I tried to explain my best.

Based on this we need to build an xml. Iam thinking on the stage variables to compare with the previous field1 values.

Any inputs would be of great help.

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

Post by eostic »

I'm not entirely sure I understand what you are trying to do, but it sounds like "duplication of some rows" may be necessary to accomplish your goal. I would probably try to figure out exactly what order of rows (and how many of them) would I need to "easily" build the xml desired.......and then manipulate the input with pivots or other techniques to build "extra" rows as needed, so that the xml can be easily created.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply