Moments of characteristic polynomials and their derivatives in the classical compact ensembles