Refactor mapref XSLT code