This is a general sort of ISO issue, and I know it's potentially nightmarish. Xpath usefully has a function
format-date
which has mind boggling parameters that I'll work out from
https://www.w3.org/TR/xpath-functions-31/#rules-for-datetime-formatting
but the obvious issue is my weeks start on Saturday.
The short term solution is to add two days to the date, and then get the year, week, day number... this will at least make the weeks line up, and 90+% of the time they'll be correct, sadly it isn't just an edge case of the 1st/last week of the year, because if the 1st week number is wrong, then all the week numbers in that year will be wrong.
So, how do I get
weeknumber
weekdaynumber
weekyear
if my weeks start on a Saturday?
The documentation (somewhere) in https://www.w3.org/TR/xpath-functions-31/#rules-for-datetime-formatting says:
So you should try to specify the language. Note that support for the variety of languages might differ based on the XSLT/XQuery/XPath processor version and edition (I think Saxon PE/EE integrate ICU to have much broader support than HE (based on the Java JRE libs) has).