Yes, you can keep attacking a gym as often as you wish, provided you have the Pokémon with health to do it. I think there is a limit to how much prestige you can have and the level of the gym, but you can train at a gym as much as you want without a cooldown, and you will get experience from it every time.
source: personal experience