I kept playing with it, and got this to work, but all data is one line (not a major problem, but would rather each line of output have one fleet):
let $doc := .
return fn:distinct-values(
for $x in $doc//Detail/@fleet
order by $x
return $x)
Any advice appreciated.
Could also add literals, and print out something like this:
where fleet = 'B-737' or 'B-738'
so I could actually generate a SQL statement?