If battery is in engine bay then the drains for the battery location could be blocked. First thing I'd do is remove the skuttle panel near the bulkhead to see if you can see any trapped leaves etc. It's the black plastic with vents either side.
https://www.audi-sport.net/xf/threads/342829/