Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

Merging Two xml files

Highlighted
Five Stars

Merging Two xml files

Hi,

 

I need to output the following xml (<personnes> are referenced in <roles>)

 

<?xml version="1.0" encoding="ISO-8859-15"?>
<data>
<destinataire oneattribute="blabla"/> <personnes> <personne ID_personne="Contrat_1_personne1" anotherattribute="X"/> <personne ID_personne="Contrat_2_personne1" anotherattribute="Y"/> <personne ID_personne="Contrat_2_personne2" anotherattribute="Z"/> </personnes> <contrats> <contrat ID_contrat="Contrat_1" num_contrat="Contrat_1Num" ref_ID_produit="Fonds" ref_ID_conseiller="conseillerToto"> <roles> <role ref_ID_personne="Contrat_1_personne1" code_role="S"/> </roles> <support_composants> <support_composant ID_support_composant="Produit A" ref_ID_support_info_generale="ISIN_Produit A"/> <support_composant ID_support_composant="Produit B" ref_ID_support_info_generale="ISIN_Produit B"/> </support_composants> </contrat> <contrat ID_contrat="Contrat_2" num_contrat="Contrat_2Num" ref_ID_produit="Fonds" ref_ID_conseiller="conseillerToto"> <roles> <role ref_ID_personne="Contrat_2_personne2" code_role="S"/> <role ref_ID_personne="Contrat_2_personne1" code_role="S"/> </roles> <support_composants> <support_composant ID_support_composant="Produit A" ref_ID_support_info_generale="ISIN_Produit A"/> <support_composant ID_support_composant="Produit B" ref_ID_support_info_generale="ISIN_Produit B"/> <support_composant ID_support_composant="Produit C" ref_ID_support_info_generale="ISIN_Produit C"/> </support_composants> </contrat>
</contrats>
</data>

 I have no difficulties to generate independantly or combined in the same input all the nodes in rows but I am struggling to generate the output.

I tried several solutions using tMaps, tXMLMaps (with lookups) + tFileOutputXML but cannot achieve my aim.

 

One of the last I have tried was to generate two different xml for <role> and <support_composant> :

<?xml version="1.0" encoding="ISO-8859-15"?>
<contrats>
  <contrat ID_contrat="Contrat_1" num_contrat="Contrat_1Num" ref_ID_produit="Fonds" ref_ID_conseiller="conseillerToto">
    <roles>
      <role ref_ID_personne="Contrat_1_personne1" code_role="S"/>
    </roles>
  </contrat>
  <contrat ID_contrat="Contrat_2" num_contrat="Contrat_2Num" ref_ID_produit="Fonds" ref_ID_conseiller="conseillerToto">
    <roles>
      <role ref_ID_personne="Contrat_2_personne2" code_role="S"/>
      <role ref_ID_personne="Contrat_2_personne1" code_role="S"/>
    </roles>
  </contrat>
</contrats>
<?xml version="1.0" encoding="ISO-8859-15"?>
<contrats>
  <contrat ID_contrat="Contrat_1" num_contrat="Contrat_1Num" ref_ID_produit="Fonds" ref_ID_conseiller="conseillerToto">
    <support_composants>
      <support_composant ID_support_composant="Produit A" ref_ID_support_info_generale="ISIN_Produit A"/>
      <support_composant ID_support_composant="Produit B" ref_ID_support_info_generale="ISIN_Produit B"/>
    </support_composants>
  </contrat>
  <contrat ID_contrat="Contrat_2" num_contrat="Contrat_2Num" ref_ID_produit="Fonds" ref_ID_conseiller="conseillerToto">
    <support_composants>
      <support_composant ID_support_composant="Produit A" ref_ID_support_info_generale="ISIN_Produit A"/>
      <support_composant ID_support_composant="Produit B" ref_ID_support_info_generale="ISIN_Produit B"/>
      <support_composant ID_support_composant="Produit C" ref_ID_support_info_generale="ISIN_Produit C"/>
    </support_composants>
  </contrat>
</contrats>

And I cannot mix them, I think I'm losing myself in the loops and grouping features...

 

Anyone has a clue?

Thanks


Accepted Solutions
Highlighted
Moderator

Re: Merging Two xml files

Hello,

Here is a 'append the source xml file' feature on tAdvanceFileOutputXML component.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

View solution in original post

Highlighted
Five Stars

Re: Merging Two xml files

Thanks Sabrina, tFileOutputMSXML made it... at last ;-)

View solution in original post


All Replies
Highlighted
Five Stars

Re: Merging Two xml files

To add up to my issues, I don't have the [...] button next to the loop elements in my tXMLMap (ESB 6.5.1), maybe I'm missing something because so far my XMLOuputs multiply the inputs as opposed to add them to each other. I get something like:

contrats
   contrat 1
      roles
         role contrat_1_personne1
      /roles
      support_composants
         support_composant product_A
      /support_composants
   /contrat
   contrat 1
      roles
         role contrat_1_personne1
      /roles
      support_composants
         support_composant product_B
      /support_composants
   /contrat
   contrat 2
      roles
         role contrat_2_personne1
      /roles
      support_composants
         support_composant product_A
      /support_composants
   /contrat
.......
/contrats
Highlighted
Five Stars

Re: Merging Two xml files

Here is one of my last tries...

 

Capture.JPG

 

Capture.JPG

Highlighted
Moderator

Re: Merging Two xml files

Hello,

Here is a 'append the source xml file' feature on tAdvanceFileOutputXML component.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

View solution in original post

Highlighted
Five Stars

Re: Merging Two xml files

Thanks Sabrina, tFileOutputMSXML made it... at last ;-)

View solution in original post

Highlighted
Five Stars

Re: Merging Two xml files

Hi again xdshi, thanks also for your tip: I suspect it will be the clue to finalize my "global" xml. Best regards

Highlighted
Six Stars

Re: Merging Two xml files

Hello,

For merging two xml files its okay with FileOutputMSXML , but I have around 10 xml files.I would like to put all together in one xml file.As there are many loops ,which composant I can use to solve my issue?

 

Thanks in advance for your reply,

 

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read