The WJ 4.0 does not have the same motor mount holes in the side as the XJ. Also, you are going to run into problems with accessories. The WJ intake is different and so the power accessory brackets. Assuming you get past the motor mount issue, you would have to change the intake and use the old brackets. Also the alternator is larger, so use that bracket too. All sensors must be used from the WJ. The computer will not swap from the XJ, different language, so you have to use the old ECM too. The XJ uses an AW4 tranny and the Wj uses a 42RE and again, the electronics will not swap. This really is not practical.
find yourself a wrecked
WJ and go from there