One Star

how to generate hierarchical xml file (with many loops) ?

I understand that it's not possible to generate an XML file with more than one loop.
so, what's the solution to generate a pretty simple XML file like this one ??? :
(reflecting a relationnal model : client --> command --> product --> item)
<clients>
<client>
<id>1</id>
<commands>
<command>
<date>31/07/2008<date>
<products>
<product>
<id>100</id>
<quantity>1</quantity>
<items>
<item>
<serialNumber>87964543213213</serialNumber>
</item>
</items>
<unitPrice>222.50</unitPrice>
<product>
<product>
<id>105</id>
<quantity>2</quantity>
<items>
<item>
<serialNumber>546546542154987</serialNumber>
</item>
<item>
<serialNumber>546546543137766</serialNumber>
</item>
</items>
<unitPrice>74.99</unitPrice>
<product>
</products>
</command>
<commands>
<command>
<date>28/07/2008<date>
<products>
<product>
<id>108</id>
<quantity>1</quantity>
<unitPrice>55.00</unitPrice>
<items>
<item>
<serialNumber>11145874587</serialNumber>
</item>
</items>
<product>
</products>
</command>
</commands>
<client>
<client>...
</client>
</client>
4 REPLIES
One Star

Re: how to generate hierarchical xml file (with many loops) ?

I used the tAdvancesFileOutputXML and imported your XML (had to fix some errors in the XML first). Set the looping on item and grouping on command. Then i could easily map the data. See screenshot.
One Star

Re: how to generate hierarchical xml file (with many loops) ?

ok, thanks a lot for your answer !
i understand that, -generally speaking- i always have to put the "loop" status on the deepest repeatable element in my structure and then put the "group" status on all the others repeatable ones.
maybe one improvment of the XML Output file could be a component able to receive more than one input link, in order to keep the relationnal structure of the inputs (and to avoid the flatenning of the model).
One Star

Re: how to generate hierarchical xml file (with many loops) ?

Hi, I've been trawling the forums trying to find a solution, but these topics all seem to cater for XML with only one Group and one repeating (looping) element.
Given that the tAdvancedXMLOutput does not have built-in support for more complex transformation, what is the reccomended solution for transforming a flat file to XML output such as:
<root>
<customer>
...
<items>
<item>1</item>
<item>2</item>
</items>
<otherthings>
<thing>1</thing>
<thing>2</thing>
</otherthings>
</customer>
<customer>
...
<items>
<item>3</item>
<item>4</item>
<item>5</item>
</items>
<otherthings>
<thing>3</thing>
<thing>4</thing>
</otherthings>
</customer>
</root>
Thanks for your help guys!
One Star

Re: how to generate hierarchical xml file (with many loops) ?

hi,
as i undestand it's not possible to have many loops at the same level of the XML structure, like in your example.
It's -today- a strong limitation in talend to produce XML files...