The "obvious" solution would be to use a Cloner with your query result as number of copies, followed by a ListBuilder.
You can also accomplish the same thing using Python, it is probably also more efficient, performance-wise:
import fmeobjects
def generate_list(feature):
items_to_create = int(feature.getAttribute('count') or 0) + 1
items = r''] * items_to_create
feature.setAttribute('list{}', items)
You need to supply an attribute "count" and it will return a list called "list{}" with count+1 elements containing an empty string, e.g. for count = 5:
`list{0}' has value `'
`list{1}' has value `'
`list{2}' has value `'
`list{3}' has value `'
`list{4}' has value `'
`list{5}' has value `'
The "obvious" solution would be to use a Cloner with your query result as number of copies, followed by a ListBuilder.
You can also accomplish the same thing using Python, it is probably also more efficient, performance-wise:
import fmeobjects
def generate_list(feature):
items_to_create = int(feature.getAttribute('count') or 0) + 1
items = r''] * items_to_create
feature.setAttribute('list{}', items)
You need to supply an attribute "count" and it will return a list called "list{}" with count+1 elements containing an empty string, e.g. for count = 5:
`list{0}' has value `'
`list{1}' has value `'
`list{2}' has value `'
`list{3}' has value `'
`list{4}' has value `'
`list{5}' has value `'
Yes, it works :-) But how can I fill values for every element of list?
For example:
- `list{0}' has value 0
- `list{1}' has value 1
- `list{2}' has value 2
- `list{3}' has value 3
- `list{4}' has value 4
- `list{5}' has value 5
Thank You so much!
Yes, it works :-) But how can I fill values for every element of list?
For example:
- `list{0}' has value 0
- `list{1}' has value 1
- `list{2}' has value 2
- `list{3}' has value 3
- `list{4}' has value 4
- `list{5}' has value 5
Thank You so much!
For example:
import fmeobjects
def generate_list(feature):
items_to_create = int(feature.getAttribute('count') or 0) + 1
for n in range(items_to_create):
feature.setAttribute('list{%s}' % n, n)
Interestingly the XMLXQueryExtractor with this XQuery expression works as well. Just for your information.
fme:set-list-attribute("list{}", (0 to xs:integer(fme:get-attribute("count"))))
# I personally call this transformer "XQueryCaller".
Interestingly the XMLXQueryExtractor with this XQuery expression works as well. Just for your information.
fme:set-list-attribute("list{}", (0 to xs:integer(fme:get-attribute("count"))))
# I personally call this transformer "XQueryCaller".
That's an interesting hack. Guess you could call that one the XQueryListPopulator
Interestingly the XMLXQueryExtractor with this XQuery expression works as well. Just for your information.
fme:set-list-attribute("list{}", (0 to xs:integer(fme:get-attribute("count"))))
# I personally call this transformer "XQueryCaller".
Great tip @takashi! It works too and probably it is more suitable solution!