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
Using http://xml.coverpages.org/bosakShakespeare200.html | |
Timing BaseX 7.9 GUI find command, numbers in parentheses are fails | |
q1:to be or not to be | |
q2:Brevity is the soul of wit | |
index defined q1 q2 | |
--------------------------------- | |
none 500ms 400ms | |
fulltext~5mb 30ms 3ms |
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
(:~ | |
: JSON test apb 2dec 2014 | |
:) | |
module namespace page = 'json-test'; | |
declare variable $page:data:=<json objects="json _"> | |
<total type="number">15</total> | |
<entity>app</entity> | |
<items type="array"> |
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
(: Java8 XQuery Javascript :) | |
declare namespace se="java:javax.script.ScriptEngine"; | |
declare namespace sm="java:javax.script.ScriptEngineManager"; | |
let $engine:= sm:getEngineByName(sm:new(),"nashorn") | |
return ( | |
se:put($engine,"a","This string is encoded!"), | |
se:eval($engine,"escape(a)") | |
) |
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
import module namespace eval = "quodatum.eval" at "../../../app-doc/src/doc/lib/eval.xqm"; | |
let $s:=" | |
declare variable $state as element(state):=db:open('doc-doc','/state.xml')/state; | |
(replace value of node $state/hits with 1+$state/hits, | |
1+$state/hits) | |
" | |
let $b:= eval:update($s,"",map{}) | |
return ($b,$b?result+100) |
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
(: let $combs:=[(),1,2,3,(1,2),(2,3),(1,3),(1,2,3)] :) | |
declare function local:powerset($items as item()* ) | |
as array(*){ | |
if (count($items)=0) then [()] | |
else let $x:=local:powerset(tail($items)) | |
return array:join(($x, | |
array:for-each($x,function($v){head($items),$v})) | |
) | |
}; |
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
(:~ | |
: tail recursion example | |
:) | |
declare function local:sum-a($n){ | |
if($n eq 0) then 1 else $n+ local:sum-a($n - 1) | |
}; | |
declare function local:sum-b($n){ | |
local:sum-iter(1,$n) | |
}; |
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
declare function local:result($id){ | |
try{ | |
map{ "result":async:result($id) | |
} | |
} catch * { | |
map{ "error": map { | |
'code': $err:code, | |
'description': $err:description, | |
'module': $err:module, | |
'line': $err:line-number, |
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
declare namespace trang="java:com.thaiopensource.relaxng.translate.Driver"; | |
trang:new()=> trang:run( | |
("C:\Users\andy\git\qd-cmpx\src\main\content\components.rnc" | |
,"C:\Users\andy\git\qd-cmpx\src\main\content\output.xsd") | |
) |
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
(: ebnf to Java parser for BaseX using REx :) | |
declare function local:REx-request($ebnf as xs:string,$name as xs:string,$command as xs:string)as item()+{ | |
let $req:= | |
<request xmlns="http://expath.org/ns/http-client" href='http://www.bottlecaps.de/rex/' method="post"> | |
<multipart media-type="multipart/form-data" boundary="xyzBouNDarYxyz"> | |
<header name="Content-Disposition" value='form-data; name="command"'/> | |
<body media-type="text/plain"/> | |
<header name="Content-Disposition" value='form-data; name="input"; filename="{$name}.ebnf"'/> | |
<body media-type="text/plain"/> | |
</multipart> |
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 page = 'http://basex.org/modules/web-page'; | |
declare | |
%rest:path("content") | |
%rest:produces("application/json") | |
%output:method("json") | |
function page:content1(){ | |
<json type="object"> | |
<msg>Hello</msg> | |
</json> | |
}; |