It'll fit, and has been done. You'll need the 'puter and wiring harness from the donor vehicle, as well as the tranny computer (behind the glove box).
The AW4 auto tranny in the XJ has never come from the factory in a Wrangler. It's a good strong overdrive tranny for the swap.
The
transfer case in the cherokee is clocked lower than in the YJ, so you'll need to redrill the mounting flange on the end of the AW4 tranny to clock the
transfer case up. You'll also need a different transfer case input shaft if you use your current 231 transfer case.