This file contains 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
xquery version "3.1"; | |
(: forked from https://gist.github.com/apb2006/4eef5889017be4a50685a467b2754d27 | |
: with tests returned in the style of https://so.nwalsh.com/2020/10/09-fib :) | |
declare function local:fib($n as xs:integer, $a as xs:integer, $b as xs:integer){ | |
switch ($n) | |
case 0 return $a | |
case 1 return $b | |
default return local:fib($n - 1, $b, $a + $b) |
This file contains 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
xquery version "3.0"; | |
(: discovered via https://twitter.com/_james_fuller/status/1087706435176288257, updated with HTTP URL for data.xq :) | |
(: the power of algebraic data types in xquery | |
This example shows how we can composite up data models | |
which 'carry' their own operations along with them. | |
:) |
This file contains 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
xquery version "3.1"; | |
declare namespace fos="http://www.w3.org/xpath-functions/spec/namespace"; | |
declare function local:writeHeader() as xs:string { | |
' | |
xquery version "3.1"; | |
module namespace xqfunctions="http://exist-db.org/xquery/test/xqfunctions"; |
This file contains 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
xquery version "3.1"; | |
let $uri := "http://openlibrary.org/search.json?title=digital+humanities" | |
let $json := fetch:text($uri) | |
return $json |
This file contains 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
xquery version "3.1"; | |
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
let $set-up-collections := | |
( | |
xmldb:create-collection('/db', 'test'), | |
xmldb:create-collection('/db/system/config/db', 'test') | |
) | |
let $in-memory-node := |
This file contains 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
xquery version "3.1"; | |
declare namespace html="http://www.w3.org/TR/REC-html40"; (: the version of HTML used by the URL below :) | |
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; (: use XQuery 3.1's JSON serialization :) | |
import module namespace http="http://expath.org/ns/http-client"; (: @see http://expath.org/spec/http-client :) | |
declare option output:method "json"; | |
declare option output:media-type "application/json"; |