XML Element Order in tXMLMap Document

One Star

XML Element Order in tXMLMap Document

Hi,
I have a job that pretty much reads the content of a text file and transforms the data into an XML File.
The structure of XML is a lot complex involving multiple Loops. Hence instead of using tAdvanced XML, I created the Job in such a way, that data from multiple sources is read and created as a document in tXMLMap.
I write the document into an XML File using tFileoutputDelimited.
And now the job is working perfectly fine. The problem arises post XML creation, since i have to validate the XML with an XSD using tXSDValidator. As per the XSD definition, i need to have the XML Elements in a particular order. Though i have the tXMLMap document properly structured as in the expected order, the XML file created has a different sequence order and Hence the XSD Validation Fails every time.
Please Help!
One Star

Re: XML Element Order in tXMLMap Document

sandeeppareek - share with us a screenshot of your job...
If I were in your shoes, I'd do the following:
+ Assuming you have multiple data flows into your tXMLMap, I'd make sure the order of processing matches the hierarchy of the XSD, starting with the main or root node down...
+ For each data flow coming in, make sure you add an order by clause on each select statement or input, using the right set of keys, from the root node down to the children nodes etc...
I once ran into this issue, but it was using the tFileOutputMSXML, and I ordered the data flows correctly and used order by clauses and it worked..
One Star

Re: XML Element Order in tXMLMap Document

Thanks for your response Willm.
Actually, the problem is that the output XML has multiple loops and the option to enable multiple loops couldn't be found in tFileoutputXML. Hence i changed my approach to tXMLMap Document type field as seen in the image. My Job has two primary data source. Header and Detail.
The output XML has three primary nodes with many attributes. The order of three nodes is not in order as it is defined in the tXMLMap Document Field structure.
One Star

Re: XML Element Order in tXMLMap Document

Hi sandeeppareek - in that case, I can confirm with all certainty that this issue does not occur when using the tFileOutputMSXML component... Here's something I'd done... http://www.talendforge.org/forum/viewtopic.php?pid=129892#p129892
In this case, you bring in the data flows in order (much like you did using tXMLMap), and 'stitch' them together to the parents within the component...
Let me know if you decide to try this approach and if it works for you.