Dynamical phase transitions in the two-dimensional XY model