if (!external) {
QName name = createQName(node.getName(), moduleCtx.getDefaultFunctionNamespaceUri());
int arity = node.getParameters().size();
UserDefinedXQueryFunction f = (UserDefinedXQueryFunction) moduleCtx.lookupFunction(name,
arity);
Signature sign = f.getSignature();
TranslationContext tCtx = new TranslationContext(null, new EmptyTupleSourceOperator());
XQueryVariable[] params = new XQueryVariable[arity];
for (int i = 0; i < arity; ++i) {
ParamNode pNode = node.getParameters().get(i);
QName pName = createQName(pNode.getName());
SequenceType pType = SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_STAR);
if (pNode.getType() != null) {
pType = createSequenceType(pNode.getType());
}
XQueryVariable pVar = new XQueryVariable(pName, pType, newLogicalVariable());
params[i] = pVar;
tCtx.varScope.registerVariable(pVar);
}
f.setParameters(params);
LogicalVariable var = translateExpression(node.getBody(), tCtx);
ILogicalExpression expr = treat(vre(var), sign.getReturnType());
var = createAssignment(expr, tCtx);
f.setBody(new ALogicalPlanImpl(mutable(tCtx.op)));
}
break;
}