AnsweredAssumed Answered

Selectively update an XML file

Question asked by simon.wallis287933 on Oct 3, 2016
Latest reply on Oct 5, 2016 by simon.wallis287933

I'm currently trying to find a way to combine two XML documents, in a scenario where the first document is a complete record, and the second document is a subset with some 'update' values.  The output I need is the first document with the fields over-written where they have been supplied in the second document - a simplified example being:

 

First (complete) record:

<record id="1">

 <title>Mr</title>

 <firstName>John</firstName>

 <lastName>Smith</lastName>

 ...

 ...

</record>

Second (update) record:

 

<record id="1">

 <firstName>Bob</firstName>

</record>

and the desired output:

<record id="1">

 <title>Mr</title>

 <firstName>Bob</firstName>

 <lastName>Smith</lastName>

 ...

 ...

</record>

 

Any of the fields may be supplied on the update record - so therefore the output could just be the entire second record if every field is given.

 

I've thought of having a map that takes in the first file as input, then the second file from a document cache, with some function that decides which value to use on the output profile.  However, for the real requirement there are many more fields than the above example, and I need to apply this logic in quite a few places/profiles - so I'm wondering if there's a more scalable way of doing it.

 

I've been looking at merging using a data processing step but can't think of a way to make it fit the above example.  Any ideas anyone has would be appreciated!

Outcomes