This is how I have my fog lights hooked up. There are some things that I did wrong because I am very lazy, but it all works.
The fog lights that I hooked up are Hella 500s and another pair of old Hellas that I got from a friend.
I will talk about the fog lights that are on the roof rack first and because the ones on the bumper are easy, any idiot could run the wires to the bumper.
The first thing you have to do is run a wire from the area where you want your switch to be and leave plenty of slack. I ran the wire along the door trim and then out at the ton and over the rain gutter. I used black wire so that it would not stand out much and I used blue wire for the ground just to help me keep it all straight. After the wire is at the roof rack get a bunch fo wire ties and run the wire on the back side of the railing all the way to your light using the wire ties to secure it. When you get to the first light run it in the light and hook it up like it is supposed to be and run a ground wire out with slack and leave it for then. Here I used a wire splice thing that taps into the first wire running to the first light and then ran the next wire to the next light and so on. I did the same with the ground so that I ended up with one ground wire.
When I had the power wire ran and hooked up I had to find a ground spot for the lights that is close and will not come loose. I used the rain gutter at first, do not do that. The rain gutter is not a good grounding point. The best option is to get a test light and test the factory roof rack runner things. I found that only one of mine was grounded well so i found a screw under the rubber and grounded it there.
For the back lights I ran a second wire up how I ran the first one and hooked them up the same way and found another screw on the same part of the roof rack to ground them to. I decided to wire my rear fog lights on a switch instead of to my back-up lights so that if anyone is following me too close I can illustrate to them that I do not appreciate it.
Now that the lights are wired you have to give them power. The best thing to do is get an 8 or 10 guage wire run it to the battery to under your dash. To get the wire through the firewall there is usually a hole predrilled in the firewall with a plug in it. In the XJ it is to the right of the steering colum. The fog lights came with a relay. You will have to look at the instructions to see where on the relay each wire hooks up.
Next is the switch. You will hook one wire up to either the wire from the battery that you ran or to the fuse box because this wire is just used to light up the switch when it is on, you also need to hook the switch up to the ground, just somewhere on the chasis, and finally the third wire goes to your relay.
If you do not want to use a switch (I didnt use one on the driving lights on my bumper, I hooked the lights up to the parking lights). You can get another one of those wire taps that you used on the lights on the roof and tap into the wire running to the parking lights. The wire on an xj is in a huge loom of other wires. It takes a lot of poking with a test light with the parking lights on to find the wire. Once you find it tap into it and run that wire to the relay where the switch hooks in.
By the way, ALWAYS make sure you have your lights fused!! I made that mistake because a ground was barely touching a power wire inside one of the lights and it blew half of the fuses in my box. It would have been easier and cheaper to just fuse the main power wire.