I don't believe the NEC will cover this other than to say you must install per mfg. specs. If the transformer is in the attic it may cause excessive heat and do some damage to it. I try not to install the transformers in the attics however, I have in the past and I can't say I ever had trouble with them. They were the magnetic type for doorbells. The electronic ones may be more sensitive to heat and I would bet the manufacturer will at least tell you they discourage use in the attic.