Skip to main content

This might rather be a simple task, but so far i have no clue how it works to merge and concatenate joined_list elements.

I want to concatenate the two element values into one string and at the end write all the list elements out into one attribute.

Result should be {KA:28,KA:12,KA:4}

if you like to stick to transformers (rather then diving into some snaky script)

you could just explode the list and string-concatenate depthto and strat. As every index in the list is a record.

Then rebuild the list (list builder, no group by) with these concatenated items and use listconcatenator to create one attribute.

Finally, stringconcatenator to get the curly braces on.


But if you did want to dive into some snaky script, something like this in a python caller would work

import fme
import fmeobjects

def concat_list(feature):
    depthto = feature.getAttribute('_join_list{}.depthto')
    strat = feature.getAttribute('_join_list{}.strat')
    for i, val in enumerate(depthto):
         feature.setAttribute('newlist{'+str(i)+'}.newattribute',depthtoti]+strat'i]) 

 


Alternatively, XQuery can also be used, although it's not XML operation.

XQuery expression:

let $start := fme:get-list-attribute('_join_list{}.start')
let $depthto := fme:get-list-attribute('_join_list{}.depthto')
for $i in (1 to count($start))
return $startt$i]||':'||$depthtot$i]

0684Q00000ArLREQA3.png


thanks for the two variants, both of which work great - have to try out also the xquery...


Reply