File: Data.xml
0001
name 1
0002
name 2
0003
name 3
File: Query.xquery
for $model in distinct-values(doc("Data.xml")/order/car/@model)
return element {$model}
{doc("Data.xml")/order/car[@model = $model]/name}
Output:
name 1
name 2
name 3