X-ray absorption spectra and electronic structures of post-transition-metal intercalates ofTiS2andNbS2