Vehicle Speed Sensors

By default, the 1999 XJ uses an electrical speedo gear.   The speedo gear is still mechanical but sends an electrical signal to the PCM.
If your speedometer is acting on the fritz, likely the VSS (Vehicle Speed Sensor) needs replacement.   
JB SuperShort SYE

Vehicle Speed Sensor Wiring Pins
L to R with Clip on Top:
3 Sensor Signal
2 Ground
1 5v supply