X-ray absorption study at the Mg and O K edges of ultrathin MgO epilayers on Ag(001)