build method to use an already parsed document