<?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: Merge nodes from two source XML documents into one XML document in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Merge-nodes-from-two-source-XML-documents-into-one-XML-document/m-p/2296607#M69255</link>
    <description>Hi &amp;nbsp;
&lt;BR /&gt;You have to define the loop element on tAdvancedFileOutputXML, so now I don't see a direct way to merge nodes without loop element, need to extract fields from source XML file and rewrite a new XML file.
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
    <pubDate>Mon, 11 Jul 2016 04:29:19 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-07-11T04:29:19Z</dc:date>
    <item>
      <title>Merge nodes from two source XML documents into one XML document</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Merge-nodes-from-two-source-XML-documents-into-one-XML-document/m-p/2296606#M69254</link>
      <description>I am currently trying to merge data from two source XML documents with the same schema into a single XML document.&amp;nbsp; The output XML document must adhere to the same schema as the two source files. 
&lt;BR /&gt;My example case for this job is simple so as to ease debugging.&amp;nbsp; Each source file contains a flatorders element, which contains one or more order elements.&amp;nbsp; See the following as an example: 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="ISO-8859-15"?&amp;gt;&lt;BR /&gt;&amp;lt;flatorders&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;order orderid="889923"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;orderperson/&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToName&amp;gt;Ola Nordmann&amp;lt;/shipToName&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToAddress&amp;gt;Langgt 23&amp;lt;/shipToAddress&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToCity&amp;gt;4000 Stavanger&amp;lt;/shipToCity&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToCountry&amp;gt;Norway&amp;lt;/shipToCountry&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/order&amp;gt;&lt;BR /&gt;&amp;lt;/flatorders&amp;gt;&lt;/PRE&gt; 
&lt;BR /&gt;The idea is to take the order nodes from each of the source files and append them into a single output file.&amp;nbsp; The output file should have one flatorders node, which would contain all of the order nodes from both files. 
&lt;BR /&gt;Since in the future, I'd like to use this example to merge documents of a much greater complexity, I don't want the program to need to know about the contents of an order.&amp;nbsp; Nor do I wish to map individual order fields.&amp;nbsp; I simply want it to copy the order element in its entirety to the output file.&amp;nbsp; That being the case, I decided to use the Document datatype to hold orders en route. 
&lt;BR /&gt;However, when I built and ran the job, I found that it was 
&lt;B&gt;almost &lt;/B&gt;doing what I wanted.&amp;nbsp; However, Talend appeared to have added the name of the Document object ("order") as an encapsulating element.&amp;nbsp; As an example, see the following.&amp;nbsp; Note the extra order elements encapsulating each order. 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;BR /&gt;&amp;lt;flatorders&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;order&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;order orderid="889923"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToName&amp;gt;Ola Nordmann&amp;lt;/shipToName&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToAddress&amp;gt;Langgt 23&amp;lt;/shipToAddress&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToCity&amp;gt;4000 Stavanger&amp;lt;/shipToCity&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToCountry&amp;gt;Norway&amp;lt;/shipToCountry&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/order&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/order&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;order&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;order orderid="889924"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToName&amp;gt;Snoid Florgsbottom&amp;lt;/shipToName&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToAddress&amp;gt;Thatone St&amp;lt;/shipToAddress&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToCity&amp;gt;City of Dreams&amp;lt;/shipToCity&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shipToCountry&amp;gt;The Wilderness&amp;lt;/shipToCountry&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/order&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/order&amp;gt;&lt;BR /&gt;&amp;lt;/flatorders&amp;gt;&lt;/PRE&gt; 
&lt;BR /&gt;I suspected that when I created a Document object, Talend assumes that the name of the object itself is an element.&amp;nbsp; Therefore, when appending the order to the final document, it wraps the contents of the Document in another order element. 
&lt;BR /&gt;Is there a way to prevent this 
&lt;B&gt;without&lt;/B&gt; needing to use tXMLMap to manually parse out each field?&amp;nbsp; If I were to use more complex datasets, manually mapping each field to the output field using tXMLMap would be tedious.&amp;nbsp; 
&lt;BR /&gt;As a reference, here are a few screenshots of my job. 
&lt;BR /&gt;Here are the input file settings and components for my job.&amp;nbsp; I've set the xPath query to "/flatorders/order" 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MEKc.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/137408i63B76896346FE5A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MEKc.png" alt="0683p000009MEKc.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;Here is the input file schema.&amp;nbsp; It contains a single Document type called "order." 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MENG.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139493i72A25C665DD440D0/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MENG.png" alt="0683p000009MENG.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;And finally, here are the settings for the tAdvancedFileOutputXML component. 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009ME5r.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/133505iB8F88583B020816B/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009ME5r.png" alt="0683p000009ME5r.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Thu, 23 Jun 2016 18:01:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Merge-nodes-from-two-source-XML-documents-into-one-XML-document/m-p/2296606#M69254</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-23T18:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Merge nodes from two source XML documents into one XML document</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Merge-nodes-from-two-source-XML-documents-into-one-XML-document/m-p/2296607#M69255</link>
      <description>Hi &amp;nbsp;
&lt;BR /&gt;You have to define the loop element on tAdvancedFileOutputXML, so now I don't see a direct way to merge nodes without loop element, need to extract fields from source XML file and rewrite a new XML file.
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
      <pubDate>Mon, 11 Jul 2016 04:29:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Merge-nodes-from-two-source-XML-documents-into-one-XML-document/m-p/2296607#M69255</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-11T04:29:19Z</dc:date>
    </item>
  </channel>
</rss>

