XQuery distinct-values removes repeated atomic values rather than selecting representative source nodes. I rebuild a small sorted XML result from repeated text. The example also keeps an empty document in view.
XQuery FLWOR: Filter and Rebuild a Small XML Result
XQuery FLWOR can iterate over source items and construct a different XML result. I use it to filter three products and reorder the survivors. The new elements deliberately differ from the source elements.



