Refactor edit xml generating to model