Generate xml with 3 records within the tags

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
rajadommeti
Premium Member
Premium Member
Posts: 43
Joined: Wed Feb 27, 2008 1:08 am

Generate xml with 3 records within the tags

Post by rajadommeti »

Hi,

We are getting data from database and generating XML. Requirement is output XML has to close and open new tag after every 3 records.
I am using XML Input stage to generate XML.



Here is the sample XMLi have to generate.

<CustomerData>
<TRANSACTIONID>1</TRANSACTIONID>
<PLATENUMBER>JUNE618</PLATENUMBER>
<TRANSACTIONID>2</TRANSACTIONID>
<PLATENUMBER>JULY19B</PLATENUMBER>
<TRANSACTIONID>3</TRANSACTIONID>
<PLATENUMBER>RK004</PLATENUMBER>
</CustomerData>
<CustomerData>
<TRANSACTIONID>4</TRANSACTIONID>
<PLATENUMBER>JUNE618</PLATENUMBER>
<TRANSACTIONID>5</TRANSACTIONID>
<PLATENUMBER>JULY19B</PLATENUMBER>
<TRANSACTIONID>6</TRANSACTIONID>
<PLATENUMBER>RK004</PLATENUMBER>
</CustomerData>
<CustomerData>
<TRANSACTIONID>7</TRANSACTIONID>
<PLATENUMBER>JUNE618</PLATENUMBER>
<TRANSACTIONID>8</TRANSACTIONID>
<PLATENUMBER>JULY19B</PLATENUMBER>
<TRANSACTIONID>9</TRANSACTIONID>
<PLATENUMBER>RK004</PLATENUMBER>
</CustomerData>

Please give me some insight
RAJ
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use @INROWNUM to count the records, stage variables to assemble the XML, and Mod(@INROWNUM,3) = 0 as the output link constraint expression.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Start by playing with the xmlOutput Stage. Take the xml that you have shown us above, save it into a disk file, and then use the xml metadata importer to bring it in and select the lowest level check boxes for each of the elements specified under <customer data>. PUt that tabledef on the input link of your xmlOutput Stage....choose the "aggregate" option and then feed a few rows from your flat file into it.....

...there will be more to it than that, but this will get you started.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
rajadommeti
Premium Member
Premium Member
Posts: 43
Joined: Wed Feb 27, 2008 1:08 am

Post by rajadommeti »

Thanks Ray and Ernie.
RAJ
Post Reply