on 2021 Jul 25 8:25 AM
Is there any way to merge two XML using groovy in CPI based on condition .
Though I can do this using content enricher but it is not a best practice when it comes to bulk load (several thousands of records).
Consider I have two XML files from two request replies
XML1:
</PerPerson>
<PerPerson>
<personIdExternal>1234</personIdExternal>
<dateOfBirth>1953-07-06T00:00:00.000</dateOfBirth>
</PerPerson>
<PerPerson>
<personIdExternal>5678</personIdExternal>
<dateOfBirth>1962-05-27T00:00:00.000</dateOfBirth>
</PerPerson>
</PerPerson>
XML2:
<PerPersonal>
<PerPersonal>
<firstName>QWE</firstName>
<lastName>ASD</lastName>
<personIdExternal>1234</personIdExternal>
</PerPersonal>
<PerPersonal>
<firstName>LKJH</firstName>
<lastName>LPOI</lastName>
<personIdExternal>5678</personIdExternal>
</PerPersonal>
</PerPersonal>
OUTPUT XML: Based on personIdExternal merging should happen
</PerPerson>
<PerPerson>
<personIdExternal>1234</personIdExternal>
<dateOfBirth>1953-07-06T00:00:00.000</dateOfBirth>
</PerPerson>
<PerPersonal>
<firstName>QWE</firstName>
<lastName>ASD</lastName>
<personIdExternal>1234</personIdExternal>
</PerPersonal>
<PerPerson>
<personIdExternal>5678</personIdExternal>
<dateOfBirth>1962-05-27T00:00:00.000</dateOfBirth>
</PerPerson>
<PerPersonal>
<firstName>LKJH</firstName>
<lastName>LPOI</lastName>
<personIdExternal>5678</personIdExternal>
</PerPersonal>
</PerPerson>
Any script idea on this ?
Thanks
Shiva
Request clarification before answering.
Hello Shiva,
If you are using navigations ( in a single query you can get PerPerson and PerPresonal ) then dont think there will be huge differerence on performance compared to writing a script to perform correlation.
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Shiva, there is one more way to solve this, you can use HashMap to store only related content and use content XML writer to get the desired output, this will be simple and fast as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Shiva,
Please try concept of navigation which avoids usage of multiple calls to SFSF.Refer below blog and make use of levels while modeling your SFSF odata query.
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
29 | |
9 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.