the important thing is how much control you have over the dog. If you can teach the dog that anything you do is fun and rewarding, then you have a better chance of control. Teach your dog that playing games with you is fun and the commands for stop and come. when he goes to chase the sheep, you should be able to make him stop, you then call him and run away and divert his interest to playing with you.
Do you know that he's going to attach the sheep or just wants to round them up? Maybe if he just wants to round up then keeping him on a leash next to them will quiet his desire. Maybe, with the farmer's permission, a small amount of rounding up would be great exercise for him.
I don't think you'll be able to train this desire out of him, but you can either distract him or let him have a go at the rounding up.
How about a muzzle when he's out?
_________________________
-- Murray I What part of 'no' don't you understand? Is it the 'N', or the 'Zero'?