• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » how to generate hierarchical xml file (with many loops) ?

#1 2008-08-01 17:51:02

bal75
New member
Registered: 2008-06-16
Posts: 7

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>

Offline

#2 2008-08-01 21:52:47

robvonk
Member
Company: Capire
Registered: 2007-10-25
Posts: 14
Website

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.


Uploaded Images

Last edited by robvonk (2008-08-01 22:16:29)

Offline

#3 2008-08-03 13:58:14

bal75
New member
Registered: 2008-06-16
Posts: 7

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).

Last edited by bal75 (2008-08-03 13:59:32)

Offline

#4 2008-08-04 07:44:12

cmora
New member
Registered: 2008-08-04
Posts: 2

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!

Last edited by cmora (2008-08-04 07:45:21)

Offline

#5 2008-08-05 10:56:29

bal75
New member
Registered: 2008-06-16
Posts: 7

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...

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » how to generate hierarchical xml file (with many loops) ?

Board footer

Powered by FluxBB