Fix invalid document