There comes a time when most XJ40 sunroof panels start to rust along the edge, some people just touch up where they can but under the edge sealing rubber there will be lots of hidden rust and the only way to do the job properly is to remove the panel.
To remove the panel first open the sunroof far enough so you can see 5 cross head screws with the screw heads facing the front of the car.
Using a magnetic screwdriver remove these and then wind the roof forwards until its just 2inches from being closed.
You may at this point want to protect the roof mask round the apeture edges put blankets down whatever, you dont want to slip with the panel and damage the roof and all that that would involve to put right.
Anyway now the screws are out and the roof partialy closed if you lift the front edge the panel will rise, you will feel some restriction as the sealing rubber is slightly wider the the opening, just be brave but careful, as you lift the front of the panel pull it forwards towards the front and the car and hopefully out it comes.
When out of the car you can strip the panel down for de rusting and paint.
Of course refitting is just the reverse of removal.