Skip to content

Instantly share code, notes, and snippets.

View mathias-goebel's full-sized avatar
🎠
black pony

Mathias mathias-goebel

🎠
black pony
View GitHub Profile
@mathias-goebel
mathias-goebel / restore.xq
Last active October 20, 2017 08:35
eXist-db restoring from XQuery
xquery version "3.1";
declare function local:do($path-external as xs:string, $path-internal as xs:string) {
let $list := file:list( $path-external )
return (
for $dir in $list/file:directory
let $name := replace(string( $dir/@name ), "\s", "_")
return(
@mathias-goebel
mathias-goebel / convert.xq
Created December 12, 2017 10:53
TCF to sentence in plain text
xquery version "3.1";
declare namespace dta="http://www.dspin.de/data/textcorpus";
declare function local:load-dta($source, $target) {
let $collection-uri := $target,
$directory := $source,
$pattern := "**/*",
$mime-type := "application/xml",
$preserve-structure := true()
@mathias-goebel
mathias-goebel / wikidata.xq
Created September 3, 2018 16:16
wikidata to dracor
xquery version "3.1";
import module namespace functx="http://www.functx.com";
declare namespace tei="http://www.tei-c.org/ns/1.0";
let $path := "......../dlina/GerDraCor and Wikidata.csv"
let $rows :=
(file:read-binary($path)
=> util:binary-to-string()
=> tokenize("\n"))[position() gt 1]
@mathias-goebel
mathias-goebel / wikidata.xq
Created September 3, 2018 16:16
wikidata to dracor
xquery version "3.1";
import module namespace functx="http://www.functx.com";
declare namespace tei="http://www.tei-c.org/ns/1.0";
let $path := "......../dlina/GerDraCor and Wikidata.csv"
let $rows :=
(file:read-binary($path)
=> util:binary-to-string()
=> tokenize("\n"))[position() gt 1]
@mathias-goebel
mathias-goebel / convert.xq
Created December 10, 2018 13:30
eXist-db http client with easyrdf converter
xquery version "3.1";
let $content :=
<httpclient:fields>
<httpclient:field name="data" value="" type="string"/>
<httpclient:field name="in" value="guess" type="string"/>
<httpclient:field name="out" value="rdfxml" type="string"/>
<httpclient:field name="raw" value="1" type="string"/>
<httpclient:field name="uri" value="http://njh.me/" type="string"/>
</httpclient:fields>
@mathias-goebel
mathias-goebel / http-post-form.xql
Created April 9, 2020 04:39
EXPath HTTP Client post form data – an example
let $parameter1 := "one"
let $parameter2 := "two"
let $parameter3 := "three"
let $boundary := current-dateTime() => util:hash("md5") => substring(0,17)
let $request :=
<hc:request method="POST" href="{ $webauthUrl }" http-version="1.0">
<hc:header name="Connection" value="close" />
<hc:multipart media-type="multipart/form-data" boundary="------------------------{$boundary}">
<hc:header name="Content-Disposition" value='form-data; name="parameter1"'/>
<hc:body media-type="text/plain">{$parameter1}</hc:body>