How to create XML Document with Multiple Repeated Elements

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
Qualta
Participant
Posts: 2
Joined: Wed May 15, 2013 9:21 am

How to create XML Document with Multiple Repeated Elements

Post by Qualta »

I have a requirement in which i have to generate a xml document with multiple repeated elements using xml output stage. I can able to successfully generate the Xml file with one repeated element, I can't able to create with multiple repeated elemnts. Please help me in achieveng this....here is the scenario

Below is the format which I required

Code: Select all

	<InternalReleaseList>
		<InternalRelease>
			<TitleName>Higher Ground</TitleName>
			<TitleID>38323</TitleID>
			<InternalReleaseID>33410</InternalReleaseID>
			<RentrakID>64855</RentrakID>
			<ReleaseIndicatorList>
				<ReleaseIndicator>AMCSelect</ReleaseIndicator>
				<ReleaseIndicator>SensoryFriendlyFilm</ReleaseIndicator>
			</ReleaseIndicatorList>
			<MediaFormatName>35mm</MediaFormatName>
			<MPAARatingCode>R</MPAARatingCode>
			<PerformanceScheduleList>
				<PerformanceSchedule>
					<TheatreNumber>2798</TheatreNumber>
					<AuditoriumID>4</AuditoriumID>
					<ShowDateTime>2011-11-20T16:00:00</ShowDateTime>
					<RadiantPerformanceID>82399</RadiantPerformanceID>
				</PerformanceSchedule>
				<PerformanceSchedule>
					<TheatreNumber>2798</TheatreNumber>
					<AuditoriumID>4</AuditoriumID>
					<ShowDateTime>2011-11-22T13:30:00</ShowDateTime>
					<RadiantPerformanceID>82442</RadiantPerformanceID>
				</PerformanceSchedule>
				<PerformanceSchedule>
					<TheatreNumber>2798</TheatreNumber>
					<AuditoriumID>4</AuditoriumID>
					<ShowDateTime>2011-11-20T13:30:00</ShowDateTime>
					<RadiantPerformanceID>82398</RadiantPerformanceID>
				</PerformanceSchedule>
				<PerformanceSchedule>
					<TheatreNumber>2798</TheatreNumber>
					<AuditoriumID>4</AuditoriumID>
					<ShowDateTime>2011-11-18T10:45:00</ShowDateTime>
					<RadiantPerformanceID>82353</RadiantPerformanceID>
				</PerformanceSchedule>
			</PerformanceScheduleList>
		</InternalRelease>
	</InternalReleaseList>

Here InternalRelease, ReleaseIndicator and PerformanceSchedule are repetable elments..I can able to successfully handle InternalRelease and ReleaseIndicator repeatability, but I am not able to handling the PerformanceSchedule..

Below is the format which I am getting..

Code: Select all

			<InternalRelease>
			<TitleName>Higher Ground</TitleName>
			<TitleID>38323</TitleID>
			<InternalReleaseID>33410</InternalReleaseID>
			<RentrakID>64855</RentrakID>
			<ReleaseIndicatorList>
				<ReleaseIndicator>AMCSelect</ReleaseIndicator>
				<ReleaseIndicator>SensoryFriendlyFilm</ReleaseIndicator>
			</ReleaseIndicatorList>
			<MediaFormatName>35mm</MediaFormatName>
			<MPAARatingCode>R</MPAARatingCode>
			<PerformanceScheduleList>
				<PerformanceSchedule>
					<TheatreNumber>2798</TheatreNumber>
					<AuditoriumID>4</AuditoriumID>
					<ShowDateTime>2011-11-20T16:00:00</ShowDateTime>
					<RadiantPerformanceID>82399</RadiantPerformanceID>
				</PerformanceSchedule>
			</PerformanceScheduleList>
		</InternalRelease>
		<InternalRelease>
			<TitleName>Higher Ground</TitleName>
			<TitleID>38323</TitleID>
			<InternalReleaseID>33410</InternalReleaseID>
			<RentrakID>64855</RentrakID>
			<ReleaseIndicatorList>
				<ReleaseIndicator>AMCSelect</ReleaseIndicator>
				<ReleaseIndicator>SensoryFriendlyFilm</ReleaseIndicator>
			</ReleaseIndicatorList>
			<MediaFormatName>35mm</MediaFormatName>
			<MPAARatingCode>R</MPAARatingCode>
			<PerformanceScheduleList>
				<PerformanceSchedule>
					<TheatreNumber>2798</TheatreNumber>
					<AuditoriumID>4</AuditoriumID>
					<ShowDateTime>2011-11-22T16:00:00</ShowDateTime>
					<RadiantPerformanceID>82443</RadiantPerformanceID>
				</PerformanceSchedule>
			</PerformanceScheduleList>
		</InternalRelease>
Instead of creating PerformanceSchedule repeatable heirarchy it is creating seperate record.

Can any one please help me with this..

Thanks in Advance
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Are you using the older XML Pack or the newer XML Assembly? From memory the old XML Pack, via the XML Output stage, cannot do this but the new XML Assembly has an XML compose stage that makes this possible.
pnpmarques
Participant
Posts: 35
Joined: Wed Jun 15, 2005 9:27 am

Post by pnpmarques »

Hello,
I believe that with xml output stage it should be possible to get what you want. Make sure that the column selected as Key is correct.
The order of the input records is also important since records from the same key must be together.
And of course be careful if you are processing in parallel mode, if you don't have performance issues set your stage to sequential.
Regards,
Pedro.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

You can do this with the older xmlOutput Stage, but it takes multiple iternations within the job, where you create each repeating node and then put them all together.......search the forum here for threads pointing to Kim Duke's site where you will find an invaluable document on XML Best Practices.....it describes in detail how to handle many things, among them the technique needed to write multiple repeating nodes.

As Vincent notes, if you have 8.5+, this can be accomplished in one Stage using the xml Stage...

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Qualta
Participant
Posts: 2
Joined: Wed May 15, 2013 9:21 am

Post by Qualta »

Hi All,

Thanks for the replies and I am sorry for late response. Yes I am using oldeer XML pack (Xml output stage), that's why I am not getting expecting results.

And I alredy tried multiple iternations within the job, even that one also does not gave me the results because one of the repeatable field "ReleaseIndicator" is generating through Pivot(Horizontal) stage(As I need to send 11 fields results to one field), so the xml is not able to grouping the same key result.

So work around as temporary fix I did removed the pivot stage and creating 11 different fields instead of sending 11 fields results to one field in xml and after generating the xml I am renaming all 11 fields names with "ReleaseIndicator" throgh Unix script, Now I am getting expecting results, but it just a temp fix..I still need to work this out through datastage.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

The method used to create the xml won't matter.....go look at it again, and find and review the best practices document noted above. You will have one xml stage for each of your repeating groups (or at least for the first two)....then for the third, you combine the others with it after performing a lookup......the method can be time consuming, but it works.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Follow my tag.
Mamu Kim
Post Reply