Oh, yeah, it'll fit no problem. I've seen, like, at least 30 of those swaps done.
Kidding of course. Nobody knows, it's never been done. You're in uncharted territory. Good luck and such, but we're not holding our breath on an "I did it!" post from you in a year or so.
Also, you don't modify the engine (and transmission and transfer case) to fit the Xterra, you have to modify the Xterra (extensively) to fit the engine and such.
_________________________
Tip: see if your question has already been answered before asking it. Try our handy-dandy search tool!