Accurate density functional calculations of near-edge X-ray and optical absorption spectra of liquid water using nonperiodic boundary conditions: The role of self-interaction and long-range effects