Merge record metadata into multiple XML files

Hi,

I have a workflow task that reads a CSV file and processes each row, populating some metadata variables as it goes. Part of this process takes one of the variables and grabs an XML file to move and concatenate into a newly sorted file.

I need to be able to add the metadata variables into a new XML node in the file before writing it out to the folder and concatenating.

Is this possible and if so how should I approach it?

Regards,

Mark

I’d probably make use of the datamapper for this.

Get the variables from the CSV, load the appropriate XML file and run it into the Datamapper while passing in the variables from the CSV. See here for passing workflow variables to a datamapping.

The datamapping will then be responsible for putting those variables in the appropriate locations. Finally, upon executing the data mapping, choose the option to output as XML and you’re done. It’ll give you a new XML file based on your datamodel and data.

Otherwise, you could always attempt this by using javascript (complicated unless you’re already well versed in Javascript), or by opening the XML as a text file and injecting the values in at the appropriate locations (easy, but also very easy to break the XML file unintentionally).

Perfect @AlbertsN, I’ll give it a go later. Just to confirm I need a datamapper with extra preprocessor automation variables set up to hold the data coming from the CSV?

This I can then pass to the folder output with concatenate set on to push all the XML files into a single file with the extra nodes.

Regards,

Mark

No, you can`t simply concatenate XML like that.

Your datamapper will read in all of the values from your XML and also insert the CSV values from the workflow variables into the datamodel. In the end, the datamodel should look exactly like what you want the final XML file to look like.

Then you`ll execute that datamapping, output as XML, and overwrite the old XML (or backup the old XML elsewhere and use the modified one going forward. backups are safest).

True, however, i will use each record processed as the dataset and run it through the Create PDF, then use a merge PDF on the folder - having seen that the xml is ill formed as you mentioned from the concatenation.

Thanks for the datamapper idea though, saves writing it as javascript to get the same result.