You can select both the second and third attributes for concatenation.
Then to remove duplicate use the AttributeSplitter, ListDuplicateRemover and ListConcatenator in sequence.
Not a really charming way, but it works.
You can select both the second and third attributes for concatenation.
Then to remove duplicate use the AttributeSplitter, ListDuplicateRemover and ListConcatenator in sequence.
Not a really charming way, but it works.
I created a little example.
example.fmw
I recently discovered an interesting usage of XQeury expressions with a JSONTemplater and this might be a typical case where the usage can be applied effectively. I would like to share the potential with all of you.
See this workspace example: aggregate-records-with-json.fmwt (FME 2017.0)
JSONTemplater ROOT Template Expression: Aggregate the XML elements created by the SUB expression grouping by field1, and return a JSON object which contains desired values created with XQuery functions.
let $t := <t>{fme:process-features("SUB")}</t>return { "field1": fme:get-attribute("field1"), "field2": fn:string-join(fn:distinct-values({for $v in $t/s/@f2 return $v}), ","), "field3": fn:string-join(fn:distinct-values({for $v in $t/s/@f3 return $v}), ",")}
JSONTemplater SUB Template Expression: Create an XML element containing the values of field2 and field3 as XML attributes for each record.
<s f2="{fme:get-attribute("field2")}" f3="{fme:get-attribute("field3")}" />
I recently discovered an interesting usage of XQeury expressions with a JSONTemplater and this might be a typical case where the usage can be applied effectively. I would like to share the potential with all of you.
See this workspace example: aggregate-records-with-json.fmwt (FME 2017.0)
JSONTemplater ROOT Template Expression: Aggregate the XML elements created by the SUB expression grouping by field1, and return a JSON object which contains desired values created with XQuery functions.
let $t := <t>{fme:process-features("SUB")}</t>return { "field1": fme:get-attribute("field1"), "field2": fn:string-join(fn:distinct-values({for $v in $t/s/@f2 return $v}), ","), "field3": fn:string-join(fn:distinct-values({for $v in $t/s/@f3 return $v}), ",")}
JSONTemplater SUB Template Expression: Create an XML element containing the values of field2 and field3 as XML attributes for each record.
<s f2="{fme:get-attribute("field2")}" f3="{fme:get-attribute("field3")}" />
Another thought. Looks like simpler.
JSONTemplater ROOT Template Expression:
{
"field1": fme:get-attribute("field1"),
"field2": fn:string-join(fn:distinct-values(fme:get-list-attribute("_list{}.field2")), ","),
"field3": fn:string-join(fn:distinct-values(fme:get-list-attribute("_list{}.field3")), ",")
}<br>