Build XML document correctly if it's missing