}
}
public Function readFunction(Element element) throws IOException {
Function function = new Function();
String id = element.getAttributeValue("id");
if (id == null)
throw new InvalidModuleException("Function definition missing required 'id' attribute");
function.setId(id);
List children = element.getChildren();
for (int i=0; i<children.size(); i++) {
Element child = (Element)children.get(i);
String name = child.getName().toLowerCase();
if (name.equals("info"))
function.setInfo(infoSerializer.readFunctionInfo(child));
else if (name.equals("parameters"))
function.setParameters(paramListSerializer.readList(child));
else if (name.equals("outputs")) {
List outputs = new ListSerializer(outputSerializer, "output").readList(child);
function.setOutputs(outputs);
}
else if (name.equals("script")) {
Script script = scriptSerializer.readScript(child);
if (script != null)
function.addScript(script);
}
}
// validate (set function title to id if absent):
if (function.getInfo() == null)
function.setInfo(new FunctionInfo());
//if (function.getInfo().getTitle() == null)
// function.getInfo().setTitle(function.getId());
return function;
}