From my own experience, I believe that all other troops in the target city must be destroyed before transport ships are targeted. This means that if you are attacking by land, you may kill all of your opponent's land troops, but if they have any remaining light ships/biremes/etc, you will not destroy any transport ships. Equally, if you are attacking with naval units only, you may destroy all naval defences, but if there are land troops left in the city, you will not destroy the transport ships.
This may be wrong, in which case hopefully someone will correct me.