Created
September 30, 2011 09:44
-
-
Save wcandillon/1253284 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module namespace script-1 = "http://www.news.org/lib/script1"; | |
import module namespace xqddf = "http://www.zorba-xquery.com/modules/xqddf"; | |
import schema namespace news-schemas = "http://www.news.org/schemas/schemas"; | |
import module namespace news-data = "http://www.news.org/lib/data"; | |
declare sequential function script-1:insert() { | |
xqddf:insert-nodes($news-data:employees, (<employee id="100">....</employee>, ..., <employee id="500">...</employee>)); | |
xqddf:insert-nodes($news-data:articles, | |
rest:get("http://www.reuters.com.xml/article234.xhtml")//article); | |
}; | |
declare sequential function script-1:get() { | |
for $emp in xqddf:collection($news-data:employees)[./position/@kind eq "journalist"] | |
let $articles := for $art in xqddf:collection($news-data:articles)[.//author//name eq $emp/name] | |
order by $art//date | |
return $art | |
return | |
<result> | |
{$emp} | |
<articles>{$articles//title}</articles> | |
</result> | |
}; | |
declare sequential function script-1:remove() { | |
xqddf:delete-nodes($news-data:articles, | |
xqddf:collection($news-data:articles)[.//date lt xs:date("01/01/2000")]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment