Skip to content

Instantly share code, notes, and snippets.

View xquery's full-sized avatar

James Fuller xquery

View GitHub Profile
@xquery
xquery / gist:7643288
Last active July 29, 2021 06:36
webdav the api you never knew existed
add file
curl -X PUT --anyauth --user 'admin:admin' -T cluster1.xml 'http://localhost:8005/testfile.xml'
make directory
curl -X MKCOL --anyauth --user 'admin:admin' 'http://localhost:8005/testdir'
move a file
curl -X MOVE --anyauth --user 'admin:admin' --header 'Destination: http://localhost:8005/testfile1.xml' 'http://localhost:8005/testfile.xml'
list all files in webdav
@xquery
xquery / gist:8001858
Created December 17, 2013 08:38
lexical closure in xquery 3 - see how the inline function 'sees' the variable $b ... neat right ?
let $b := 2
return
map(function($x) { $x * $x * $b }, 1 to 5)
@xquery
xquery / gist:9057019
Last active August 29, 2015 13:56
playing around with this and @jpcs parser.xq, yes dashes ....
{
"p-pipeline": [
{
"name": "my-pipeline",
"p-import": "../test.xpl",
"p-source": {
"sequence": false
},
"p-results": {},
"myuri": "http://www.example.org/test.xslt",
@xquery
xquery / gist:3b527eaf04a02dc7f693
Last active August 29, 2015 14:02
simple markov chain example using xquery (requires MarkLogic)
xquery version "1.0-ml";
import module namespace functx = "http://www.functx.com" at
"/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
(: extracts //p from web page and tokenizes to lower case words :)
declare function local:generate-corpus(
$uri
){
@xquery
xquery / gist:885d227151ee9ee9ac06
Created September 9, 2014 15:24
check out the new annotations for RXQ functions (%output: , %xdmp:gzip) ... neat
(: -------------------------------------------------------------------------- :)
(: XSLT and XQuery Serialization 3.0 :)
(: -------------------------------------------------------------------------- :)
declare
%rxq:produces('text/plain')
%output:method('text')
%output:encoding('iso-8859-1')
%output:omit-xml-declaration('no')
### Keybase proof
I hereby claim:
* I am xquery on github.
* I am jimfuller (https://keybase.io/jimfuller) on keybase.
* I have a public key whose fingerprint is F971 F4C2 13BB BE1A FF88 9AB4 0617 80A7 7257 D3E2
To claim this, I am signing this object:
@xquery
xquery / gist:350831de91841b84edd9
Created February 13, 2015 16:54
xslt fold example - apply a series of xslt against a single source doc
the following is an example of a left fold xslt
java -jar /Applications/depify-1.0/deps/xmlcalabash/calabash.jar -isource=test.xml -istylesheets=test1.xsl -istylesheets=test2.xsl -oresult=- xslt-fold.xpl
<p:declare-step version="1.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:ex="http://www.example.com"
name="main">
@xquery
xquery / gist:4eebf54c11aa48f88ca1
Last active August 29, 2015 14:15
xproc tests run via gradle
apply plugin: 'izpack'
defaultTasks 'assemble', 'test'
ant.importBuild 'build.xml'
buildscript {
repositories {
mavenCentral()
jcenter()
@xquery
xquery / gist:c66bec2d3695e9026fae
Created March 15, 2015 16:40
binary search in xquery
xquery version "1.0-ml";
declare function local:binary($min,$max,$number){
let $middle := round( (($max - $min) div 2) + $min )
return
if($middle eq $number)
then $number
else
if($middle lt $number)
then local:binary($middle,$max,$number)
@xquery
xquery / test.gradle
Created April 13, 2015 11:59
Run xmlcalabash with gradle
gradle -b test.gradle -Dexec.args="-isource=test1.xpl -oresult=- test1.xpl"