Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm quite new to Talend and particularly to tXMLMap.
I'm currently working on a job that needs to produce XML output with multiple loops. From the tXMLMap documentation I thought I would be able to use tXMLMap with multiple (optional) loops and explicit groups. However, I don't seem to be getting the option to set nodes for grouping at all.
I'm starting with CSV input and some intermediate processing steps before getting to the tXMLMap
What I need to end up with (slightly simplified here as there are a lot of fields in the full XML) is
For each row of incoming data there will always need to be an InformationAsset node created but then depending on the ClosureType there will either be an AccessRegulation node or a Replica node (but never both).
If there is an AccessRegulation node there will be at least one, and possibly several, ExemptionCodeId nodes, and there will be an incoming row for each required ExemptionCodeId, all other data in those rows would be the same. In particular the RelatedToIA in the AccessRegulation node would match the IAID node in the InformationAsset node
Similarly, if there is a Replica node its RelatedToIA value would match the IAID value, and its ID node value would match the ReplicaID node value under InformationAsset. In this case it's the Folder node and its sub-nodes that may need to be looped.
Having searched around Community I've come across this https://community.qlik.com/t5/Design-and-Development/prepare-XML-with-multiple-loop-in-same-level/td... which seems to suggest this design may not actually be possible? Could someone confirm that in this instance? I had thought the fact that all other data matched meant that the looping would work, but no matter where I set it, I don't get the output I expected, and I never actually see the option to explicitly set a node as a group node. I can choose loop and then optional loop, but wherever I put those the grouping doesn't work: I either get complete node structures repeated all the way down (so I'd get either multiple nodes for AccessRegulation for each applicable ExemptionCodeID or multiple nodes for Replicas for each applicable Folders entry); or everything gets folded under the first ID for each of those regardless of the fact that the ExemptionCodeId or Folder nodes actually relate to several different incoming data rows).
Thanks in advance - I can try and add some examples if this isn't clear enough.
tXMLMap is not powerful enough to make x loop. You might consider using more than one XMLMap and then merge the data using group by for example.
If you want to achieve this with one component only you should look tHMap, using Talend Data Mapper.
One of the weird things is that I don't seem to be getting the option to explicitly group at all. Anyway, I have created an implementation of what I needed using multiple tAdvancedFileOutputXML components with append set for the components after the first.