1997 engine swap XK8

I just purchased an early XK8 (with EGR) vin 7-7th and the engine is bad. I have found a couple of replacement engines, one is a 1997 (non EGR) vin7-7th and a 1998 not sure of vin. can either be used in my car and what would be involved?
Thanks in advance’ Jay111