Calculation of near-edge x-ray-absorption spectra of molecules and polymers by a Green's-function method.