  We develop a first-principles scheme based on the continued fraction approach
an d ultrasoft pseudopotentials to calculate K-edge X-ray absorption spectra in
solids. The method allows for calculations of K-edge X-ray absorption spectra
in transition metal and rare-earths compounds with substantially reduced
cutoffs respect to the norm-conserving case. We validate the method by
calculating Si and O K-edges in $\alpha$ quartz, Cu K-edge in Copper and in
La$_2$CuO$_4$. For the case of Si and O edges in $\alpha$ quartz and in Copper
we obtain a good agreement with experimental data. In the Cu K-edge spectra of
La$_2$CuO$_4$, a material considered a real challeng e for density functional
theory we attribute all the near-edge and far-edge peaks to single particle
excitations.
