fix dead loop causing by generate full_xml for incorrect ordered doc