The result of your search is a sequence of documents.  I think you want to 
xpath down to audience for each document in your FLOWR.  Something like:

for $audience in $these-docs//ec:audience
order by $audience/@audience
return $audience/fn:string()

-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of Kari Cowan
Sent: Thursday, July 30, 2015 11:44 AM
To: [email protected]
Subject: [MarkLogic Dev General] Sorting and De-duping

I have a query that returns a group of records.

I want to display a sorted list of results of a node called 'audience' - there 
can be multiple audience nodes in a document.

Here's a snippet and result list, to put it in context.

Am I missing something obvious?


xquery version "1.0-ml";
declare namespace ec = "http://www.alm.com/event-calendar";;
let $directory:="/data-sources/editorial-calendar/"

let $these-docs:=
cts:search(
  xdmp:directory($directory),
  cts:and-query((
    cts:element-attribute-range-query(xs:QName("ec:MaterialsDueDate"), 
xs:QName("date"), ">=", xs:date(fn:current-date()) ),
    cts:element-query(xs:QName("ec:approval_status"),cts:word-query("true"))
  ))
)

for $audiences in $these-docs
order by fn:data($audiences//ec:audience/@audience)
return $audiences//ec:audience/text()


>>
Consulting
Entertainment
Food and Beverage
Consulting
Health Care/Medical
Insurance
Automotive
Real Estate
Transportation/Aviation
Education
Food and Beverage
Health Care/Medical

________________________________
Learn more about ALM, visit http://www.alm.com . - ALM, an Integrated Media 
Company, is a leading provider of news and information for the legal and 
commercial real estate markets. ALM's market-leading brands include The 
American Lawyer, Corporate Counsel, GlobeSt.com, Insight Conferences, Law.com, 
Law Journal Press, LegalTech, The National Law Journal and Real Estate Forum.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to