you might check the Coil thoroughly, then the Ignition Module, (a black square box with two wires sticking out near the ignition), those have a GM/Delco circuit inside and one of the symptoms of a bad module is just as you describe.
The next check is the large black box after the Air Filter housing; Called the AFM, Those have a circuit that fails creating a situation in which little or no air is let into the intake manifold, again, developing a similar symptom.
There is a fix to revive the AFM's circuit. you will need to study its operation to understand the fix, which entails adding a resistor to the circuit board. Where to read about it? Go to Jag-Lovers and register. (
www.jag-lovers.com ) and once registered, you can access the database and search for articles on the AFM for the Series III XJ-6 (made from 1980½ thru 1987 for the US Market). Also, there's a lot of troubleshooting information there if none of the above cure the problem.
NOTE: They kept making the Series III XJ after 1987 and until 1992 but only with 12 cylinder engine and only for the European, Canada, and Australia markets.
let us know what you discover. Overall, these cars are simple to repair, so do not be intimidated, it's just lack of familiarity at first.