Why does
(<benefitStartDate>20170101</benefitStartDate>,<benefitEndDate>20170301</benefitEndDate>,
<benefitStartDate>20170101</benefitStartDate>,<benefitEndDate>20170501</benefitEndDate>)/distinct-values(.)
yield 20170101 20170301 20170101 20170501 (i.e duplicates not eliminated)
but applying it to an atomized version of the sequence
distinct-values((20170701,20170301,20170701,20170501))
yields
20170701 20170301 20170501
is not the same as:
The latter returns the distinct-values for a sequence of elements.
Your code returns the distinct-values for each of these elements, it is like calling:
Another variant, that returns the result you expected is:
Best
Michael