You should be able to train troops in the building they are created from. I want to experience up my archers at the archery range. This should require food, gold and time. The unit would be gone for the duration of the training, but they would come out a level higher than when they went in. The max level of the training should be based on the level of the building you are training them with, and how much and how long depends on the level you are trying to achieve. This could be easily done based on the experience they need to get to the next level. If they only need 2 xp to "level-up" they training would be quick and cheep. While they are training, you can not build any more units at that facility until the training is done. But you should be able to cancel the training to get the unit back with a experience bonus and a refund based on how much time they spent.