FunctionCall call = new FunctionCall(context, func); call.setASTNode(getASTNode()); return new FunctionReference(call);
resolvedFunction = new FunctionCall(context, func); resolvedFunction.setASTNode(getASTNode()); return new FunctionReference(resolvedFunction);
    public Sequence eval(Sequence[] args, Sequence contextSequence)            throws XPathException {        String funcName = args[0].getStringValue();        int arity = ((NumericValue)args[1].itemAt(0)).getInt();        // try to parse the qname        QName qname;        try {            qname = QName.parse(context, funcName, context.getDefaultFunctionNamespace());        } catch(XPathException e) {            e.setASTNode(getASTNode());            throw e;        }                // check if the function is from a module         Module module = context.getModule(qname.getNamespaceURI());        UserDefinedFunction func;        if(module == null) {            func = context.resolveFunction(qname, arity);			if (func == null)				throw new XPathException(getASTNode(), Messages.getMessage(Error.FUNC_NOT_FOUND, qname, Integer.toString(arity)));        } else {            if(module.isInternalModule())                throw new XPathException(getASTNode(), "Cannot create a reference to an internal Java function");            func = ((ExternalModule)module).getFunction(qname, arity);        }        FunctionCall call = new FunctionCall(context, func);        call.setASTNode(getASTNode());        return new FunctionReference(call);    }