<?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 A need to unflatten xml in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202933#M4450</link>
    <description>&lt;P&gt;I have the following challenge:&lt;/P&gt;&lt;P&gt;I have a webservice that returns the following inside a job&lt;/P&gt;&lt;PRE&gt;&amp;lt;response&amp;gt;
  &amp;lt;result&amp;gt;
    &amp;lt;title&amp;gt;something&amp;lt;/title&amp;gt;
    &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
    &amp;lt;tag1&amp;gt;tag1value&amp;lt;/tag1&amp;gt;
    &amp;lt;tag2&amp;gt;tag2value&amp;lt;/tag2&amp;gt;
    &amp;lt;tag3&amp;gt;tag3value&amp;lt;/tag3&amp;gt;
    &amp;lt;tag4&amp;gt;tag4value&amp;lt;/tag4&amp;gt;
    ....
  &amp;lt;/result&amp;gt;
&amp;lt;/response&amp;gt;&lt;/PRE&gt;&lt;P&gt;And i need to change it to the following&lt;/P&gt;&lt;PRE&gt;&amp;lt;Report&amp;gt;
  &amp;lt;tagValues&amp;gt;
    &amp;lt;tagValue&amp;gt;
      &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
      &amp;lt;tagname&amp;gt;tag1&amp;lt;/tagname&amp;gt;
      &amp;lt;value&amp;gt;tag1value&amp;lt;/value&amp;gt;
    &amp;lt;/tagValue&amp;gt;
    &amp;lt;tagValue&amp;gt;
      &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
      &amp;lt;tagname&amp;gt;tag2&amp;lt;/tagname&amp;gt;
      &amp;lt;value&amp;gt;tag2value&amp;lt;/value&amp;gt;
    &amp;lt;/tagValue&amp;gt;
    &amp;lt;tagValue&amp;gt;
      &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
      &amp;lt;tagname&amp;gt;tag3&amp;lt;/tagname&amp;gt;
      &amp;lt;value&amp;gt;tag3value&amp;lt;/value&amp;gt;
    &amp;lt;/tagValue&amp;gt;
    &amp;lt;tagValue&amp;gt;
      &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
      &amp;lt;tagname&amp;gt;tag4&amp;lt;/tagname&amp;gt;
      &amp;lt;value&amp;gt;tag4value&amp;lt;/value&amp;gt;
    &amp;lt;/tagValue&amp;gt;
    ...
  &amp;lt;/tagValues&amp;gt;
&amp;lt;/report&amp;gt;&lt;/PRE&gt;&lt;P&gt;Is that at all possible?&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 07:37:40 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-11-16T07:37:40Z</dc:date>
    <item>
      <title>A need to unflatten xml</title>
      <link>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202933#M4450</link>
      <description>&lt;P&gt;I have the following challenge:&lt;/P&gt;&lt;P&gt;I have a webservice that returns the following inside a job&lt;/P&gt;&lt;PRE&gt;&amp;lt;response&amp;gt;
  &amp;lt;result&amp;gt;
    &amp;lt;title&amp;gt;something&amp;lt;/title&amp;gt;
    &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
    &amp;lt;tag1&amp;gt;tag1value&amp;lt;/tag1&amp;gt;
    &amp;lt;tag2&amp;gt;tag2value&amp;lt;/tag2&amp;gt;
    &amp;lt;tag3&amp;gt;tag3value&amp;lt;/tag3&amp;gt;
    &amp;lt;tag4&amp;gt;tag4value&amp;lt;/tag4&amp;gt;
    ....
  &amp;lt;/result&amp;gt;
&amp;lt;/response&amp;gt;&lt;/PRE&gt;&lt;P&gt;And i need to change it to the following&lt;/P&gt;&lt;PRE&gt;&amp;lt;Report&amp;gt;
  &amp;lt;tagValues&amp;gt;
    &amp;lt;tagValue&amp;gt;
      &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
      &amp;lt;tagname&amp;gt;tag1&amp;lt;/tagname&amp;gt;
      &amp;lt;value&amp;gt;tag1value&amp;lt;/value&amp;gt;
    &amp;lt;/tagValue&amp;gt;
    &amp;lt;tagValue&amp;gt;
      &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
      &amp;lt;tagname&amp;gt;tag2&amp;lt;/tagname&amp;gt;
      &amp;lt;value&amp;gt;tag2value&amp;lt;/value&amp;gt;
    &amp;lt;/tagValue&amp;gt;
    &amp;lt;tagValue&amp;gt;
      &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
      &amp;lt;tagname&amp;gt;tag3&amp;lt;/tagname&amp;gt;
      &amp;lt;value&amp;gt;tag3value&amp;lt;/value&amp;gt;
    &amp;lt;/tagValue&amp;gt;
    &amp;lt;tagValue&amp;gt;
      &amp;lt;timestamp&amp;gt;sometimestamp&amp;lt;/timestamp&amp;gt;
      &amp;lt;tagname&amp;gt;tag4&amp;lt;/tagname&amp;gt;
      &amp;lt;value&amp;gt;tag4value&amp;lt;/value&amp;gt;
    &amp;lt;/tagValue&amp;gt;
    ...
  &amp;lt;/tagValues&amp;gt;
&amp;lt;/report&amp;gt;&lt;/PRE&gt;&lt;P&gt;Is that at all possible?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 07:37:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202933#M4450</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T07:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: A need to unflatten xml</title>
      <link>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202934#M4451</link>
      <description>you may use tXmlMap were you can define or modify schema of your xml. 
&lt;BR /&gt;when you have select tXmlMap Componet on your job you can press F1 to have help and samples</description>
      <pubDate>Wed, 19 Sep 2018 10:00:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202934#M4451</guid>
      <dc:creator>fdenis</dc:creator>
      <dc:date>2018-09-19T10:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: A need to unflatten xml</title>
      <link>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202935#M4452</link>
      <description>&lt;P&gt;I don't know if it's easier to make a loop on each tag with the tXMLMap.&lt;/P&gt;&lt;P&gt;I think that the better way is to use XSL Transformation with a tXSLT component.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The content of the XSL file should be like this.&lt;/P&gt;&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;

  &amp;lt;xsl:template match="/"&amp;gt;
     &amp;lt;Report&amp;gt;
        &amp;lt;tagValues&amp;gt;
           &amp;lt;xsl:for-each select="/response/result/**"&amp;gt;
               &amp;lt;xsl:if test="name() != 'title' and name() != 'timestamp'"&amp;gt;
                  &amp;lt;tagValue&amp;gt;
                      &amp;lt;timestamp&amp;gt;&amp;lt;xsl:value-of select="/response/result/timestamp"/&amp;gt;&amp;lt;/timestamp&amp;gt;
                      &amp;lt;tagname&amp;gt;&amp;lt;xsl:value-of select="name()"/&amp;gt;&amp;lt;/tagname&amp;gt;
                      &amp;lt;value&amp;gt;&amp;lt;xsl:value-of select="."/&amp;gt;&amp;lt;/value&amp;gt;
                  &amp;lt;/tagValue&amp;gt;
               &amp;lt;/xsl:if&amp;gt;
           &amp;lt;/xsl:for-each&amp;gt;
        &amp;lt;/tagValues&amp;gt;
     &amp;lt;/Report&amp;gt;
  &amp;lt;/xsl:template&amp;gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Sep 2018 13:51:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202935#M4452</guid>
      <dc:creator>DoDo69</dc:creator>
      <dc:date>2018-09-19T13:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: A need to unflatten xml</title>
      <link>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202936#M4453</link>
      <description>&lt;P&gt;The XSLT sounds good.&lt;/P&gt;&lt;P&gt;Is there a way to apply XSLT in Talend without going through the tXSLT component (and it's need for files) for instance in a tJavaRow?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 08:47:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202936#M4453</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-20T08:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: A need to unflatten xml</title>
      <link>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202937#M4454</link>
      <description>you can use javax.xml to do it on tJavarow or tjava or tJavaFlex&lt;BR /&gt;but think about person who is going to reopen your job.&lt;BR /&gt;with tjavaxxx he have to read your code&lt;BR /&gt;with tXLST he know that it's xml transformer</description>
      <pubDate>Thu, 20 Sep 2018 08:54:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202937#M4454</guid>
      <dc:creator>fdenis</dc:creator>
      <dc:date>2018-09-20T08:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: A need to unflatten xml</title>
      <link>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202938#M4455</link>
      <description>&lt;P&gt;Yes it should be possible to do this in java in tJavaRow.&lt;/P&gt;&lt;P&gt;I think you can adapt the code present in the following link :&amp;nbsp;&lt;A href="https://gist.github.com/serge1/9307868" target="_blank" rel="nofollow noopener noreferrer"&gt;https://gist.github.com/serge1/9307868&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You just need to generate a source with a String, but I think it's possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To me, the code is very easy to understand, so I think it's not a bad way to use a tJavaRow if you don't want to write your XML in a file.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 08:56:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/A-need-to-unflatten-xml/m-p/2202938#M4455</guid>
      <dc:creator>DoDo69</dc:creator>
      <dc:date>2018-09-20T08:56:53Z</dc:date>
    </item>
  </channel>
</rss>

