X-ray versus infrared selection of distant galaxy clusters: a case study using the XMM–LSS and SpARCS cluster samples