We develop a technique based on density functional theory and the projector augmented wave method in order to obtain the x-ray absorption cross section at a general edge, both in the electric dipole and quadrupole approximations. The method is a generalization of Taillefumier et al., PRB 66, 195107 (2002). We apply the method to the calculation of the Cu L2,3 edges in fcc copper and cuprite (Cu2O), and to the S L2,3 edges in molybdenite (2H-MoS2). The role of core-hole effects, modeled in a supercell approach, as well as the decomposition of the spectrum into different angular momentum channels are studied in detail. In copper we find that the best agreement with experimental data is obtained when core-hole effects are neglected. On the contrary, core-hole effects need to be included both in Cu2O and 2H-MoS2. Finally we show that a non-negligible component of S L2,3 edges in 2H-MoS2 involves transition to states with s character at all energy scales. The inclusion of this angular momentum channel is mandatory to correctly describe the angular dependence of the measured spectra. We believe that transitions to s character states are quantitatively significant at the L2,3 edges of third row elements from Al to Ar.