<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Import one XML file into multiple tables and keep the relations in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Import-one-XML-file-into-multiple-tables-and-keep-the-relations/m-p/2362549#M126669</link>
    <description>Hi, 
&lt;BR /&gt;I have a XML file like this : 
&lt;BR /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt; 
&lt;BR /&gt;&amp;lt;PrintedProduct xmlns="editorialin" Name="AIXPR" NewsPaperName="BLP" PublicationDate="2009-10-08T00:00:00:000" Priority="50" Version="1"&amp;gt; 
&lt;BR /&gt; &amp;lt;PrintedProductDescription Structure="B34T20"&amp;gt; 
&lt;BR /&gt; &amp;lt;Section Format="Broadsheet" Layout="GABBLP" Name="A" PhysicalSectionNumber="1"&amp;gt; 
&lt;BR /&gt; &amp;lt;Page FileName="B01AIX_20091008.ps" Name="B01AIX-Q" NumberInSection="1"&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Cyan" NumberOfPlates="2" id="80001" sepId="BLP_AIXPR_0_20091008_001_C"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Magenta" NumberOfPlates="2" id="80002" sepId="BLP_AIXPR_0_20091008_001_M"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Yellow" NumberOfPlates="2" id="80003" sepId="BLP_AIXPR_0_20091008_001_Y"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Black" NumberOfPlates="2" id="80004" sepId="BLP_AIXPR_0_20091008_001_K"/&amp;gt; 
&lt;BR /&gt; &amp;lt;/Page&amp;gt; 
&lt;BR /&gt; &amp;lt;Page FileName="P2BCH_20091008.ps" Name="P2BCH-Q" NumberInSection="2"&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Cyan" NumberOfPlates="0" id="80005" sepId="BLP_AIXPR_0_20091008_002_C"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Magenta" NumberOfPlates="0" id="80006" sepId="BLP_AIXPR_0_20091008_002_M"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Yellow" NumberOfPlates="0" id="80007" sepId="BLP_AIXPR_0_20091008_002_Y"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Black" NumberOfPlates="0" id="80008" sepId="BLP_AIXPR_0_20091008_002_K"/&amp;gt; 
&lt;BR /&gt; &amp;lt;/Page&amp;gt; 
&lt;BR /&gt; &amp;lt;/Section&amp;gt; 
&lt;BR /&gt; &amp;lt;/PrintedProductDescription&amp;gt; 
&lt;BR /&gt;&amp;lt;/PrintedProduct&amp;gt; 
&lt;BR /&gt;I want to import this in a database like this : 
&lt;BR /&gt;Table "PrintProduct" : 
&lt;BR /&gt;------------------------ 
&lt;BR /&gt;Fields : 
&lt;BR /&gt;idPrintProduct (auto increment), primary key 
&lt;BR /&gt;name 
&lt;BR /&gt;date 
&lt;BR /&gt;structure 
&lt;BR /&gt;Table "Section " : 
&lt;BR /&gt;------------------------ 
&lt;BR /&gt;Fields : 
&lt;BR /&gt;idSection (auto increment), primary key 
&lt;BR /&gt;idPrintProduct (foreign key) 
&lt;BR /&gt;format 
&lt;BR /&gt;layout 
&lt;BR /&gt;name 
&lt;BR /&gt;Table "Page" 
&lt;BR /&gt;----------------------- 
&lt;BR /&gt;Fields : 
&lt;BR /&gt;idPage (auto increment), primarykey 
&lt;BR /&gt;idSection (foreign key) 
&lt;BR /&gt;fileName 
&lt;BR /&gt;name 
&lt;BR /&gt; 
&lt;BR /&gt;So i set up a metadata xml to extract the data, i do a loop on the "page" element (see the capture) 
&lt;BR /&gt; 
&lt;IMG src="https://community.qlik.com/" /&gt; 
&lt;BR /&gt;So now each row extracted from the xml contains page info, section info and printedproduct info. 
&lt;BR /&gt;Now i want to feed my three tables : 
&lt;BR /&gt;- first the PrintedProduct : a new ID is generated by the mysql database, 
&lt;BR /&gt;- then the section : i need to lookup my PrintedProduct table to retrieve the newly created ID and fill the foreign key of Section table with it, a new idSection is created by the mysql database, 
&lt;BR /&gt;- then the page : i need to lookup my Section table to retrive the newly created idSection and fill the foreign key of the Page table with it, a new idPage is created. 
&lt;BR /&gt;I have absolutely no idea of how to deal with that ! 
&lt;BR /&gt;Have i to create one tFileInputXML for each element (ie one for PrintedProduct, one for Section, one for Page), and deal with the feed of my tables separately ? 
&lt;BR /&gt;Any help would be very very appreciated !!</description>
    <pubDate>Sat, 16 Nov 2024 13:40:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-11-16T13:40:53Z</dc:date>
    <item>
      <title>Import one XML file into multiple tables and keep the relations</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Import-one-XML-file-into-multiple-tables-and-keep-the-relations/m-p/2362549#M126669</link>
      <description>Hi, 
&lt;BR /&gt;I have a XML file like this : 
&lt;BR /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt; 
&lt;BR /&gt;&amp;lt;PrintedProduct xmlns="editorialin" Name="AIXPR" NewsPaperName="BLP" PublicationDate="2009-10-08T00:00:00:000" Priority="50" Version="1"&amp;gt; 
&lt;BR /&gt; &amp;lt;PrintedProductDescription Structure="B34T20"&amp;gt; 
&lt;BR /&gt; &amp;lt;Section Format="Broadsheet" Layout="GABBLP" Name="A" PhysicalSectionNumber="1"&amp;gt; 
&lt;BR /&gt; &amp;lt;Page FileName="B01AIX_20091008.ps" Name="B01AIX-Q" NumberInSection="1"&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Cyan" NumberOfPlates="2" id="80001" sepId="BLP_AIXPR_0_20091008_001_C"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Magenta" NumberOfPlates="2" id="80002" sepId="BLP_AIXPR_0_20091008_001_M"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Yellow" NumberOfPlates="2" id="80003" sepId="BLP_AIXPR_0_20091008_001_Y"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Black" NumberOfPlates="2" id="80004" sepId="BLP_AIXPR_0_20091008_001_K"/&amp;gt; 
&lt;BR /&gt; &amp;lt;/Page&amp;gt; 
&lt;BR /&gt; &amp;lt;Page FileName="P2BCH_20091008.ps" Name="P2BCH-Q" NumberInSection="2"&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Cyan" NumberOfPlates="0" id="80005" sepId="BLP_AIXPR_0_20091008_002_C"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Magenta" NumberOfPlates="0" id="80006" sepId="BLP_AIXPR_0_20091008_002_M"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Yellow" NumberOfPlates="0" id="80007" sepId="BLP_AIXPR_0_20091008_002_Y"/&amp;gt; 
&lt;BR /&gt; &amp;lt;Color Name="Black" NumberOfPlates="0" id="80008" sepId="BLP_AIXPR_0_20091008_002_K"/&amp;gt; 
&lt;BR /&gt; &amp;lt;/Page&amp;gt; 
&lt;BR /&gt; &amp;lt;/Section&amp;gt; 
&lt;BR /&gt; &amp;lt;/PrintedProductDescription&amp;gt; 
&lt;BR /&gt;&amp;lt;/PrintedProduct&amp;gt; 
&lt;BR /&gt;I want to import this in a database like this : 
&lt;BR /&gt;Table "PrintProduct" : 
&lt;BR /&gt;------------------------ 
&lt;BR /&gt;Fields : 
&lt;BR /&gt;idPrintProduct (auto increment), primary key 
&lt;BR /&gt;name 
&lt;BR /&gt;date 
&lt;BR /&gt;structure 
&lt;BR /&gt;Table "Section " : 
&lt;BR /&gt;------------------------ 
&lt;BR /&gt;Fields : 
&lt;BR /&gt;idSection (auto increment), primary key 
&lt;BR /&gt;idPrintProduct (foreign key) 
&lt;BR /&gt;format 
&lt;BR /&gt;layout 
&lt;BR /&gt;name 
&lt;BR /&gt;Table "Page" 
&lt;BR /&gt;----------------------- 
&lt;BR /&gt;Fields : 
&lt;BR /&gt;idPage (auto increment), primarykey 
&lt;BR /&gt;idSection (foreign key) 
&lt;BR /&gt;fileName 
&lt;BR /&gt;name 
&lt;BR /&gt; 
&lt;BR /&gt;So i set up a metadata xml to extract the data, i do a loop on the "page" element (see the capture) 
&lt;BR /&gt; 
&lt;IMG src="https://community.qlik.com/" /&gt; 
&lt;BR /&gt;So now each row extracted from the xml contains page info, section info and printedproduct info. 
&lt;BR /&gt;Now i want to feed my three tables : 
&lt;BR /&gt;- first the PrintedProduct : a new ID is generated by the mysql database, 
&lt;BR /&gt;- then the section : i need to lookup my PrintedProduct table to retrieve the newly created ID and fill the foreign key of Section table with it, a new idSection is created by the mysql database, 
&lt;BR /&gt;- then the page : i need to lookup my Section table to retrive the newly created idSection and fill the foreign key of the Page table with it, a new idPage is created. 
&lt;BR /&gt;I have absolutely no idea of how to deal with that ! 
&lt;BR /&gt;Have i to create one tFileInputXML for each element (ie one for PrintedProduct, one for Section, one for Page), and deal with the feed of my tables separately ? 
&lt;BR /&gt;Any help would be very very appreciated !!</description>
      <pubDate>Sat, 16 Nov 2024 13:40:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Import-one-XML-file-into-multiple-tables-and-keep-the-relations/m-p/2362549#M126669</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T13:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Import one XML file into multiple tables and keep the relations</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Import-one-XML-file-into-multiple-tables-and-keep-the-relations/m-p/2362550#M126670</link>
      <description>I have the same question.&lt;BR /&gt;Did you find an answer or solution ?</description>
      <pubDate>Fri, 10 Dec 2010 11:43:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Import-one-XML-file-into-multiple-tables-and-keep-the-relations/m-p/2362550#M126670</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-12-10T11:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Import one XML file into multiple tables and keep the relations</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Import-one-XML-file-into-multiple-tables-and-keep-the-relations/m-p/2362551#M126671</link>
      <description>I can tell you how i've work with that :&lt;BR /&gt;solution one : &lt;BR /&gt;- read the XML file for each reference table, feed the destination table for the "reference tables" and create id's&lt;BR /&gt;- read the XML file then for the child rows, make a map between the previously feeded tables and feed each child tables. You have to make a join between the values of the xml and the values of the reference table (not the id of course because u dont know them in the xml), and put the id of the reference row matched in the child table.&lt;BR /&gt;solution two :&lt;BR /&gt;you can read only once the XML , then replicate the flox with tReplicate , then do the same than above with just a difference : for each flow, make a aggregate if needed.&lt;BR /&gt;Can be faster for huge XML files.</description>
      <pubDate>Fri, 10 Dec 2010 17:04:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Import-one-XML-file-into-multiple-tables-and-keep-the-relations/m-p/2362551#M126671</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-12-10T17:04:54Z</dc:date>
    </item>
  </channel>
</rss>

