Skip to content

Instantly share code, notes, and snippets.

@wcandillon
Created September 30, 2011 09:45
Show Gist options
  • Save wcandillon/1253289 to your computer and use it in GitHub Desktop.
Save wcandillon/1253289 to your computer and use it in GitHub Desktop.
(: The "news-data" Library Module :)
module namespace news-data = "http://www.news.org/lib/data";
import schema namespace news-schemas = "http://www.news.org/schemas/schemas";
declare collection news-data:employees as schema-element(news-schema:employee)*;
declare collection news-data:articles as node()*;
declare automatically maintained value equality index news-data:CityEmp
on nodes xqddf:collection(xs:QName("news-data:employees"))/employee
by .//station/city as xs:string;
declare manually maintained value range index news-data:ArtCountEmp
on nodes xqddf:collection(xs:QName("news-data:employees"))/employee[./position/@kind eq "journalist"]
by count(for $art in xqddf:collection(xs:QName("news-data:articles"))//article
where $art/empid eq ./id
return $art) as xs:integer;
declare variable $news-data:employees := xs:QName("news-data:employees");
declare variable $news-data:articles := xs:QName("news-data:articles");
declare variable $news-data:months := xs:QName("news-data:months");
declare variable $news-data:CityEmp := xs:QName("news-data:CityEmp");
declare variable $news-data:ArtCountEmp := xs:QName("news-data:ArtCountEmp");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment