One Star

Extract delimited varying values from field and map to xml

I've got a csv-input and want to map this to a xml structure output. So far, so simple, so good...
The input (a csv) looks like this:
===================================================
id;longtitle;shorttitle;keywords;description
12345;Longtitle 1;Shorttitle 2;dummy1 dummy2 dummy3;this is the first product
78901;Another product; other product;dummy8 dummy9;this is the second product
===================================================
My problem is the "keyword" part. As this is "dynamic" i've got no idea how to extract these values from this field and map them to my xml.
The xml output should look like this:
===================================================
<?xml version="1.0" encoding="UTF-8"?>
<root><product><id>12345</id><title><type>long</type><text>Longtitle 1</text></title><title><type>short</type><text>Shorttitle 2</text></title><keyword><text>dummy1</text></keyword><keyword><text>dummy2</text></keyword><keyword><text>dummy3</text></keyword><description>this is the first product</description></product></root>
<?xml version="1.0" encoding="UTF-8"?>
<root><product><id>78901</id><title><type>long</type><text>Another product</text></title><title><type>short</type><text> other product</text></title><keyword><text>dummy8</text></keyword><keyword><text>dummy9</text></keyword><description>this is the second product</description></product></root>
===================================================
Can anyone guide me to a sample or something else? Or provide a solution for this small sample?
Thx in advance
3 REPLIES
Moderator

Re: Extract delimited varying values from field and map to xml

Hi,
Did you check the output components TalendHelpCenter:tFileOutputXML and tAdvancedFileOutputXML.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Extract delimited varying values from field and map to xml

Hi Sabrina,
thanks for your answer.
No, i didn't checked this components (not really, just a little bit). The output should go (in real world) to a tRESTClient...
As i'm relativ new to TOS, i have no clue how to extract the delimited values in the keywords field and pass them to my xml to look like that:
<product>
...
<keyword>dummy1</keyword>
<keyword>dummy2</keyword>
...
</product>
My Problem is, that the number of values to be extracted from the keywords-field is varying. From a simple view it's like an own delimited "stream" to be extracted in several "rows" and pass every "row" as <keyword>xxxx</keyword> to my xml-structure to get the result like mentioned above.

Hope i have clearly described where my problem is. Btw, how the solution would look like with the tFileOutputXml / tAdvancedFileOutputXML?
Best regards
Andreas
One Star

Re: Extract delimited varying values from field and map to xml

OK, finally after some hours of try and error (and learning by doing) i figured out how to get the expected result.
tNormalize on the keywords field and use of a tXMLMap with proper setting of loop (on keyword) and aggregate (on id) will do the job in this sample.
I'll post the pictures showing the job as soon as i've solved some other problems and i've got time to.
Thx
-Andi