Spellbook or triggers.
The spellbook item can definitely be used for this, although I also found a means of doing this same thing with triggering, if you don't mind the work.
I created a custom ability for the item to use, then had it do something innocuous, like cast a meaningless buff for half a second. Then, I made a series of variables, denoting the powers I wanted my unit to have, and made a trigger, which activated whenever my custom item was used, which switched the two sets of powers back and forth, removing one set of powers, and adding the other one, then doing the reverse when it was clicked again, based on the custom value of the unit (1 or 0.)
I did this because I wanted to make a unit that could transform into a variety of different things, and world editor wouldn't let me do it otherwise.