Initial refactoring of view.xqy