<?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 Re: dynamic xml conversion in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293002#M66024</link>
    <description>Hi,
&lt;BR /&gt;Thanks for providing solutions here.
&lt;BR /&gt;But we don't know the possible column names. &amp;nbsp;The list can be changed any time. We don't have max columns list.
&lt;BR /&gt;New fields will be added and/or existing fields will be removed in the next file.
&lt;BR /&gt;Is there any solution for this kind of scenario?
&lt;BR /&gt;Thanks in advance.</description>
    <pubDate>Sun, 19 Jun 2016 03:12:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-06-19T03:12:54Z</dc:date>
    <item>
      <title>dynamic xml conversion</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2292998#M66020</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I have a scenario like below&lt;BR /&gt;Source - Not sure about columns/structure. one day source file come with 100 fields, next day it can be 110, another day 90. Source file with delimiter.&lt;BR /&gt;Target - We want to convert it into xml file.&lt;BR /&gt;Please provide any solutions.&lt;BR /&gt;Thanks&lt;BR /&gt;Jay&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jun 2016 18:06:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2292998#M66020</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-18T18:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic xml conversion</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2292999#M66021</link>
      <description>If you don't know the schema, how do you know the data types for your input files? Is there some method to understand the data (known header names)?&lt;BR /&gt;&lt;BR /&gt;Also, what structure are you looking to produce XML in? I am assuming it will have be a single level of elements named according to the column names.&lt;BR /&gt;&lt;BR /&gt;If you know all of the possible column names and the xml is a single level, you can do this. But it will be a mess tXMLMap.</description>
      <pubDate>Sat, 18 Jun 2016 18:14:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2292999#M66021</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-18T18:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic xml conversion</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293000#M66022</link>
      <description>Yes, we will have column names as header/first row in the file.&lt;BR /&gt;Can you explain the solution clearly</description>
      <pubDate>Sat, 18 Jun 2016 18:19:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293000#M66022</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-18T18:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic xml conversion</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293001#M66023</link>
      <description>You will need all possible column names for all files at design time. If you have that, then this tutorial I put together on something similar might help (&lt;A href="https://www.rilhia.com/tutorials/dynamic-column-order" rel="nofollow noopener noreferrer"&gt;https://www.rilhia.com/tutorials/dynamic-column-order&lt;/A&gt;). But it will be messy.&lt;BR /&gt;&lt;BR /&gt;For the XML schema, you will need to have every column preconfigured. Then in the tXMLMap, set up the "create empty element" setting for the XML output to be false.</description>
      <pubDate>Sat, 18 Jun 2016 19:33:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293001#M66023</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-18T19:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic xml conversion</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293002#M66024</link>
      <description>Hi,
&lt;BR /&gt;Thanks for providing solutions here.
&lt;BR /&gt;But we don't know the possible column names. &amp;nbsp;The list can be changed any time. We don't have max columns list.
&lt;BR /&gt;New fields will be added and/or existing fields will be removed in the next file.
&lt;BR /&gt;Is there any solution for this kind of scenario?
&lt;BR /&gt;Thanks in advance.</description>
      <pubDate>Sun, 19 Jun 2016 03:12:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293002#M66024</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-19T03:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic xml conversion</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293003#M66025</link>
      <description>OK, this is a highly unusual scenario but it tempted me to try and solve it. I have a solution. But it requires Java and is not elegant. You will need to build upon this. 
&lt;BR /&gt;For this you will need to know the maximum number of columns you might get in a file, that is all. 
&lt;BR /&gt;This is built using your source data (assuming that the first row are the column headers) and a tJavaFlex. We build the XML in the tJavaFlex and print it out in the End Code section. You can also set it to a globalMap variable and then convert it to an actual Document later if you want. I haven't covered that. I am assuming in this example that there will be columns without data and that they should not be used in the XML.&amp;nbsp; 
&lt;BR /&gt; 
&lt;BR /&gt;Below are the Start Code, Main Code and End Code sections for the tJavaFlex I used. You will need to change this to suit your job. 
&lt;BR /&gt;Start Code 
&lt;BR /&gt; 
&lt;PRE&gt;// Create a rowcount variable to keep track of where we are&lt;BR /&gt;int rowcount = 0;&lt;BR /&gt;&lt;BR /&gt;//Create a hashmap to keep the first row values (for column names) assigned to &lt;BR /&gt;//an integer to represent their column number &lt;BR /&gt;java.util.HashMap&amp;lt;Integer, String&amp;gt; columnHeader = new java.util.HashMap&amp;lt;Integer, String&amp;gt;();&lt;BR /&gt;&lt;BR /&gt;//Create the opening XML element.&lt;BR /&gt;String XML = "&amp;lt;myXML&amp;gt;";&lt;BR /&gt; &lt;BR /&gt;      &lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;Main Code 
&lt;BR /&gt; 
&lt;PRE&gt;//For row 0 create the header information&lt;BR /&gt;if(rowcount==0){&lt;BR /&gt;	columnHeader.put(1,row1.newColumn);&lt;BR /&gt;	columnHeader.put(2,row1.newColumn1);&lt;BR /&gt;	columnHeader.put(3,row1.newColumn2);&lt;BR /&gt;	columnHeader.put(4,row1.newColumn3);&lt;BR /&gt;	columnHeader.put(5,row1.newColumn4);&lt;BR /&gt;	columnHeader.put(6,row1.newColumn5);&lt;BR /&gt;	columnHeader.put(7,row1.newColumn6);&lt;BR /&gt;	columnHeader.put(8,row1.newColumn7);&lt;BR /&gt;	columnHeader.put(9,row1.newColumn8);&lt;BR /&gt;&lt;BR /&gt;}else{ //for every other row, check to see if the header is not null and then&lt;BR /&gt;//build an element for it if it is not empty.&lt;BR /&gt;&lt;BR /&gt;	XML = XML+"&amp;lt;loop&amp;gt;\n";&lt;BR /&gt;	&lt;BR /&gt;	if(columnHeader.get(1)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(1)+"&amp;gt;"+row1.newColumn+"&amp;lt;/"+columnHeader.get(1)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	if(columnHeader.get(2)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(2)+"&amp;gt;"+row1.newColumn1+"&amp;lt;/"+columnHeader.get(2)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	if(columnHeader.get(3)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(3)+"&amp;gt;"+row1.newColumn2+"&amp;lt;/"+columnHeader.get(3)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	if(columnHeader.get(4)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(4)+"&amp;gt;"+row1.newColumn3+"&amp;lt;/"+columnHeader.get(4)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	if(columnHeader.get(5)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(5)+"&amp;gt;"+row1.newColumn4+"&amp;lt;/"+columnHeader.get(5)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	if(columnHeader.get(6)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(6)+"&amp;gt;"+row1.newColumn5+"&amp;lt;/"+columnHeader.get(6)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	if(columnHeader.get(7)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(7)+"&amp;gt;"+row1.newColumn6+"&amp;lt;/"+columnHeader.get(7)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	if(columnHeader.get(8)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(8)+"&amp;gt;"+row1.newColumn7+"&amp;lt;/"+columnHeader.get(8)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	if(columnHeader.get(9)!=null){&lt;BR /&gt;		XML = XML+"&amp;lt;"+columnHeader.get(9)+"&amp;gt;"+row1.newColumn8+"&amp;lt;/"+columnHeader.get(9)+"&amp;gt;\n";&lt;BR /&gt;	}&lt;BR /&gt;	&lt;BR /&gt;	&lt;BR /&gt;		XML = XML+"&amp;lt;/loop&amp;gt;\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;//append 1 to the rowcount&lt;BR /&gt;rowcount++;&lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;End Code 
&lt;BR /&gt; 
&lt;PRE&gt;// close the XML opening tag&lt;BR /&gt;&lt;BR /&gt;XML = XML + "&amp;lt;/myXML&amp;gt;";&lt;BR /&gt;&lt;BR /&gt;System.out.println(XML);&lt;BR /&gt;      &lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Jun 2016 16:34:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-xml-conversion/m-p/2293003#M66025</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-19T16:34:02Z</dc:date>
    </item>
  </channel>
</rss>

