forNonBlank function in OpenRefine -


i error when using fornonblank in openrefine's templating export feature.

i have cells multiple subjects want capture in separate dcterms:subject xml elements. example: geology--alberta--coal valley. // geology, structural. // geology, stratigraphic--cretaceous.

i using openrefine's templating export option export xml, process described here.

this expression works fine:

{{foreach(cells["dcterms:subject"].value.split(" // "), v, "<dcterms:subject>" + v + "</dcterms:subject>\n")}}

i get:

<dcterms:subject>geology--alberta--coal valley.</dcterms:subject> <dcterms:subject>geology, structural.</dcterms:subject> <dcterms:subject>geology, stratigraphic--cretaceous.</dcterms:subject>

but when using fornonblank in:

{{fornonblank(cells["dcterms:subject"].value.split(" // "), v, "<dcterms:subject>" + v + "</dcterms:subject>\n", "")}}

i get:

<dcterms:subject>[ljava.lang.string;@16657412</dcterms:subject> 

is there wrong coding, or bug?

thanks help.

fornonblank isn't iterative function, function:

fornonblank(cells["dcterms:subject"].value.split(" // "), v, "" + v + "\n", "")

evaluates array created through split whether blank or not (the whole array, not each item in array) , finding not blank assigns array variable 'v'.

essentially 'fornonblank' doing similar combining 'if' , 'isnonblank', not 'foreach' , 'isnonblank'

you've got several options doing want, need have iterator in there somewhere. example:

foreach(cells["dcterms:subject"].value.split(" // "),v,fornonblank(v,w, "" + w + "", "")).join("/n")


Comments