Skip to content

Instantly share code, notes, and snippets.

View wcandillon's full-sized avatar

William Candillon wcandillon

View GitHub Profile
(: 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-schemas:employee)*;
declare collection news-data:articles as node()*;
declare variable $news-data:employees := xs:QName("news-data:employees");
let $x as xs:string := "Value of X"
return $x (: returns: "Value of X" :)
let $x := "Value of X"
return trace($x,"I'm tracing $x: ") (: still returns: "Value of X" :)
import module namespace guestbook = "http://www.28msec.com/templates/guestbook/guestbook";
import module namespace xqddf = "http://www.zorba-xquery.com/modules/xqddf";
let $entry:= <entry author="bulkloader"
date="2010-01-15"
time="13:25:00.000">bulkload entry</entry>
return
xqddf:insert-nodes(xs:QName("guestbook:entries"), $entry)
import module namespace guestbook = "http://www.28msec.com/templates/guestbook/guestbook";
import module namespace xqddf = "http://www.zorba-xquery.com/modules/xqddf";
let $entries := fn:doc("xml_files/old_entries.xml")//entry
return
xqddf:insert-nodes(xs:QName("guestbook:entries"), $entries)
<entries>
<entry author="bulkloader" date="2010-01-15" time="13:25:00.000">first entry</entry>
<entry author="bulkloader" date="2010-01-16" time="17:19:00.000">second entry</entry>
<entry author="bulkloader" date="2010-01-19" time="14:42:00.000">third entry</entry>
</entries>
import module namespace guestbook = "http://www.28msec.com/templates/guestbook/guestbook";
import module namespace xqddf = "http://www.zorba-xquery.com/modules/xqddf";
if (fn:exists(xqddf:collection(xs:QName("guestbook:entries"))))
then
()
else
let $entries := fn:doc("xml_files/old_entries.xml")//entry
return
xqddf:insert-nodes(xs:QName("guestbook:entries"), $entries)
import module namespace guestbook = "http://www.28msec.com/templates/guestbook/guestbook";
import module namespace xqddf = "http://www.zorba-xquery.com/modules/xqddf";
xqddf:delete-nodes(xs:QName("guestbook:entries"), xqddf:collection(xs:QName("guestbook:entries"))),
let $entries := fn:doc("xml_files/old_entries.xml")//entry
return
xqddf:insert-nodes(xs:QName("guestbook:entries"), $entries)
declare module namespace ex = "http://www.28msec.com/example";
import module namespace cookie = "http://www.28msec.com/modules/http/cookie";
declare sequential function ex:howto-set-a-cookie() {
cookie:set-cookie(
<cookie:cookie
name="examplecookie"
expires="2020-10-24T18:00:00"
path="/"