Measurement of the quark and gluon fragmentation functions in Z(0) hadronic decays