Merging Two xml files

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
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.
Five Stars

Re: Merging Two xml files

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


All Replies
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
Five Stars

Re: Merging Two xml files

Here is one of my last tries...

 

Capture.JPG

 

Capture.JPG

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.
Five Stars

Re: Merging Two xml files

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

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