You are given a date d. If that date does not fall on a weekday, you would like to find the first weekday date that follows d. The following XPath code will do the trick:
for $start in xs:date('2008-07-19') return
(: Get date plus two following dates, i.e. candidate dates :)
(for $i in (0 to 2) return
$start + xs:dayTimeDuration(concat('P', $i, 'D')))
(: Only keep date on week dates :)
[number(format-date(., '[F0]', 'en', (), ())) le 5]
(: Take first possible date :)
[1]number(format-date(xs:date('2008-08-26'),
'[F0]', 'en', (), ())) le 5




