I'm trying to extend some BAI nodes to set some attributes based on functional components named values. I'm trying to do it in a generic way but it does not work. My code is as follow

for att in ['att1','att2', 'att3'] do
attributes := search(in bai traverse FunctionalContainer:FunctionalContainment:ContainedFunctionality:FunctionalComponent where %att% defined);
if attributes then
bai[att] := attributes[0][att];
end if;
end for;

This ends up with this error:

ParseFailure: ModelCORBA.Search.ParseFailure(reason='Only attributes can be used in DEFINED expressions', token='', lineno=1L)