One Star

tMap versus tXMLMap

I saw different examples using Talend component tMap in connection with XML transformation. I wonder why and what are the differences in detail. Are there any cases where it is suggestive to use the Talend component tMap instead of tXMLMap in the transformation of XML files?
One Star

Re: tMap versus tXMLMap

Hello ohofrichter - it's a question of the data type(s) of your inputs to the transform step in your job is.
Using tXMLMap
If you have XML files that you'd like to parse and transform at the same time, then tXMLMap is the component to use. For this, you pass in a valid XML flow and you can use the XML or XSD to recreate the structure within the input 'table' in tXMLMap. Feeders for this scenario could be tFileInputXML or tExtractXMLFields. The other reason for using this scenario is where you want to directly output XML from the tranform step - not have to use a tFileOutputXML or some other component. In this case, you set one output field, set the type to 'Document' and map your inputs to output tags in your XML. Also - keep in mind that the tMap can read in raw fields and create an XML row that can be written out in the next step. In this case, it's similar to the tFileOutputMSXML.
Using tMap
In the second scenario, your inputs to the transform step is raw records - not an XML document. If you have an XML, you'd first parse it with an input XML component (like tFileInputXML), extract the raw rows and pass them to the tMap component.
Bottomline, if you're simply reading an XML file, doing a transform and either generating an XML or set of fields, tXMLMap is the right one. If you have other preprocessing on the elements within the XML, then parse if first, then tranform later.
Hope this helps somewhat...