Find duplicates in sequences of elements

1. Setup test data

The test data is regenerated for each script so the outputs are not the same.

3. Distinct Values2

as suggested by Michael Westbay

5. count

6. group

as suggested by Wolfgang - requires XQuery 3.0.