Page 1 of 1

XML construction for repeating duplicate values

Posted: Tue Oct 24, 2017 8:27 am
by parag.s.27
Hi,

I have a data condition where a customer has multiple addresses and phone numbers. I have a flat data set which looks like: -

ProfileID1 Address1 Phone1
ProfileID1 Address1 Phone2
ProfileID1 Address2 Phone1
ProfileID1 Address2 Phone2

When I am constructing the XML messages via XML composer, the result set is forming like :-

Code: Select all

<ProfileData>
	<ProfileID>ID1</ProfileID>
		<Address>Address1</Address>
		<Address>Address2</Address>
		<Address>Address1</Address>
		<Address>Address2</Address>
		<Phone>Phone1</Phone>
		<Phone>Phone2</Phone>
		<Phone>Phone1</Phone>
		<Phone>Phone2</Phone>
</ProfileData>
But Actually I need the payload construct as: -

Code: Select all

<ProfileData>
	<ProfileID>ID1</ProfileID>
		<Address>Address1</Address>
		<Address>Address2</Address>
		<Phone>Phone1</Phone>
		<Phone>Phone2</Phone>
</ProfileData>
This is just a representation data but there are many such attributes that are repeating due to Cartesian product in the flat data set.

Is there a way to do a de-duplication within XML composer?

Other ways to resolve this is done but they are not efficient. For e.g.: -

1. Construct separate XMLs for repeating elements and then join them and edit the XML

2. Create Java wrapper Jar that transforms the data in the required XML based on the XSD.

Posted: Tue Oct 24, 2017 2:00 pm
by ray.wurlod
Why do you claim using separate elements for the different repeating groups is inefficient? It's a good way to get the job done, and pretty much self-documenting.