I'm constructing an XML query for a WFS service by using an XMLTemplater. The ROOT element is this:
<Filter>
<Or>
{fme:process-features("SUB")}
</Or>
</Filter>
And the SUB element, per feature, is this
<PropertyIsEqualTo><PropertyName>identificatie</PropertyName><Literal>{fme:get-attribute("bag_vbo_id")}</Literal></PropertyIsEqualTo>
Store in an attribute then use that feature to trigger a FeatureReader and use the query attribute. This works fine and results in a working query. Except when there's only one feature, in that case the WFS service seems to bork about the unnecessary <Or> </Or> tags.
My workaround:
- StringSearcher to count the number of times </PropertyIsEqualTo> occurs (i.e. the number of sub elements)
- ListElementCounter on the list of matches
- TestFilter to test for the number of elements
- If 1 StringReplacer to replace the <Or> and </Or> with empty strings
I can't help but think there's got to be an easier way to do this... I could combine steps 3 and 4 in one conditional value, saving me one transformer, but it still amounts to the same thing really. Any other suggestions?