TXmlMap include document field in output xml

Five Stars

TXmlMap include document field in output xml

Hello everybody
I'm developing a POST REST service which have to get the input xml, transform it, and call a soap service.
in_xml:
<items>
   <item>
       <id>
       <des>
       <list of characteristic>
             <char>
                  <cod>
                   .....
             </char>
       </list of characteristic>
       <list of prices>
             <price>
                   <class>
                   <value>
             </price>
             ......
       </list of prices>
   </item>
   .....
</items>             


in order to remap xml_in I thought to use textractXMLFileds looping over list of characteristic/Char tag.
I've created a ListOfPrices field(type document ) where to collect the entire </list of prices> node (using GetNode flag)


my queston is: how to put ListOfPrices field inside the tXmlMap configuration?
if not possible, any other ideas?

thank you
Ten Stars

Re: TXmlMap include document field in output xml

If I understand you correctly, you want to go from this....

<items>
   <item>
       <id>
       <des>
       <list of characteristic>
             <char>
                  <cod>
                   .....
             </char>
       </list of characteristic>
   </item>
   .....
</items>             

.....to this......
<items>
   <item>
       <id>
       <des>
       <list of characteristic>
             <char>
                  <cod>
                   .....
             </char>
       </list of characteristic>
       <list of prices>
             <price>
                   <class>
                   <value>
             </price>
             ......
       </list of prices>
   </item>
   .....
</items>             

By adding the list of prices section after the list of characteristic. Is that right?

If so, you can do this with a couple of extra steps to what you have already. If you already have this....

<items>
   <item>
       <id>
       <des>
       <list of characteristic>
             <char>
                  <cod>
                   .....
             </char>
       </list of characteristic>
   </item>
   .....
</items>             
[font=Verdana, Helvetica, Arial, sans-serif]....then use a tConvertType on your Document to convert it to a string. Next do the same for this section that you have created.....[/font]
       <list of prices>
             <price>
                   <class>
                   <value>
             </price>
             ......
       </list of prices>
Once you have these as strings, it is a simple find and replace using Java String manipulation. Look for "</list of characteristic>" in you main XML String and replace it with .....

"</list of characteristic>
       <list of prices>
             <price>
                   <class>
                   <value>
             </price>
             ......
       </list of prices>"



Once you've done that, just convert the resulting String to a Document using the tConvertType. 

You *may* run into an issue with having to remove the <XML> tag from the XML document you create with "List of prices". But that is pretty simple to do with a regex.

This sounds complicated but it is actually pretty simple.
Five Stars

Re: TXmlMap include document field in output xml

Sounds good!!!
should work Smiley Tongue
thanks a lot... 

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

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog