Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
David_Underdown
Contributor
Contributor

tXMLMap and multiple loops

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

  • BIA (root)
    • InformationAsset
      • IAID
      • ClosureType
      • ReplicaIdentities
        • ReplicaID
    • AccessRegulation
      • RelatedToIA
      • ClosureCriterions
        • ExemptionCodeId
    • Replica
      • Id
      • RelatedToIA
      • Folios
        • Folio
        • DigitalFiles
          • DigitalFile
            • DigitalFileDirectory @ completePath
              • Folder
                • Label
                • ID
                • ParentID

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.

Labels (3)
2 Replies
jeoste
Creator
Creator

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.

David_Underdown
Contributor
Contributor
Author

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.