One of the flaws of the Jaguar XJ8 design from the 1998-2003 model was the throttle body. It's very sensitive to carbon building up inside it which also complicates things with a TPS sensor that isn't as reliable as it should be. In my short year and a half of owning this vehicle I've had to address both of these issues first hand.
While I was able to resolve my throttle body/TPS issue by swapping out the TPS from a salvaged part in the summer, I actually had some success earlier in the spring by cleaning the throttle body altogether. While the TPS failing will actually throw you a code and will put the car into failsafe mode, a dirty throttle body will instead cause the car to stall or make it feel very jerky on acceleration. It is possible that the code and failsafe mode could be linked to a dirty throttle body, but there obviously isn't a code that tells you to clean your car.
This is something you can feel when you're driving though. It's like the RPMs will putter out when you slow down or your acceleration will feel sticky on lower revs. At the very least, knowing how to check out your throttle body is a valuable skill with this car that will save you time and money in the shop. Cleaning is a relatively simple fix for a lot of this stuff.
To summarize what you need to do, you're just trying to clean the black carbon and soot that has built up underneath the butterfly valve in your throttle body. Below I've posted pictures of what the engine looks like with the air intake tube removed. At the top of the engine is the throttle body. Cleaning it is as simple as buying throttle body cleaner, spraying it on a micro-fiber cloth, and diligently cleaning the soot from underneath the valve.
What is happening with a dirty throttle body is when that carbon/soot heats up it becomes a bit sticky and also reduces the narrow opening of the butterfly valve when the car is idling. This explains why the car feels like it's about to stall sometimes and why the acceleration feels like it's lurching more than it should.
CLICK HERE to download the step by step guide and walk through of how to specifically clean the Jaguar throttle body (with pictures illustrating the process). These are the instructions I used, and I noticed a huge difference immediately after completing this job.