It sounds like an electrical problem in the trans. Have you checked/cleaned all of the connectors going to the trans? Also you should go to this link:
http://www.lunghd.com/Downloads_and_Links/FSM.htm and download the FSM for the 1988 XJ. It will have troubleshooting info on the trans (and everything else too!)