Refactoring for Document to reduce dependency from xml