failing attempt at replacing an xquery standard function