validate xml and fix errors