[Solved] Detail table from a single XML node

Given an XML node like:
<Topics>["1;2", "4;1"; "87;4"]</Topics>

is it possible to create a detail table of 3 elements, each with two properties the first and the second value of each element?

DetailTable[1]:

  • 1
  • 2

DetailTable[2]:

  • 4
  • 1

DetailTable[3]:

  • 87
  • 4

I’m trying to fiddle with a repeat step and an extraction step with no avail, maybe I should instead use an Action script with only javascript commands?

The attached DM Config should do the trick.
It reads the array inside the Topics element and loops on its length. Inside the loop, it splits each element on the semi-colon, creating Element1 and Element2 for each detail record.

Here’s the sample config: ArrayDM.OL-datamapper

Solved with an action script indeed:

list= data.extract('./elementList[1]');

jLista = JSON.parse(list)

for (let[i, el] of jLista.entries()){
	left = el.split(';')[0];
	right = el.split(';')[1];    	

	record.tables.ElementLists.addRow( {left: left, right : right }  )
}

thanks for sharing a “ol-connect” way to accomplish the same thing! Definitively a more elegant solution.

I’d like to follow up on the example. Could you elaborate why a go to step is required and settings the repeat step collection to ./Topics doesn’t work?

OK you caught me: I was just lazy :stuck_out_tongue: and didn’t want to have to specify //root/Topics everywhere. Using the Goto step allows me to just specify . as the current element.

Here’s a version without the Goto step, works the same : ArrayDM2.OL-datamapper

1 Like

Ah that’s OK I thought there was a specific issue I wasn’t aware of!