Sure wish more folks would get in the habit of posting the year of their XJ's when asking these kinds of questions..........
Anyway, to remove the rear hatch on an '84 - '96 XJ, the wiring harness goes from the roof down the driver's side of the rear pilar and the connectors can be found behind the plastic interior panel behind the spare tire. You'll have to then gently pull the long harness up through the pilar and out the hole in the roof. Same with the windshield washer hose, only it can be disconnected in the space behind the hole in the roof.
The '97+ rear hatches are a little easier in that there's not a long harness to pull through the pilar, but getting to the connectors behind the hole in the roof is tight space.