How to Relate to tables and show in desing

I get and xml with to table I need to create subtotals relating two tables the fisrt is header of the other detail table

I need to do something like this

https://learn.objectiflune.com/qa-blobs/3469737060706389274.ol-template

https://learn.objectiflune.com/qa-blobs/11570613879065011013.ol-template

this kind of table is nested tables and need scripting with the actual versions.

You may find a sample in this topic https://learn.objectiflune.com/discourse/t/using-script-to-build-table/822/1