Skip to content

Instantly share code, notes, and snippets.

Magdalena Turska tuurma

  • University of Oxford
  • United Kingdom
View GitHub Profile
tuurma / setup.xq
Created Apr 12, 2019
moving from xmldb:change-user to sm
View setup.xq
xquery version "3.1";
(: create 3 accounts with personal groups and additional group :)
sm:create-account('magda', 'm-pass', ('girls', 'existsol')),
sm:create-account('lars', 'l-pass', ('boys', 'existsol')),
sm:create-account('joern', 'l-pass', ('boys', 'existsol')),
tuurma /
Last active Feb 11, 2019
exist contributions

sync develop branch with upstream by rebasing

git checkout develop
git fetch upstream develop
git rebase upstream/develop

check log to confirm commits correspond with the ones for exist/develop

tuurma / transform.xq
Created Sep 3, 2018
basic xquery typeswitch example, assumes play is encoded in TEI like
View transform.xq
xquery version "3.1";
declare namespace tei="";
declare namespace output="";
declare option output:method "html5";
declare option output:media-type "text/html";
tuurma / chown-collection.xquery
Created Jul 16, 2018
change owner, group an permissions for subcollections
View chown-collection.xquery
xquery version "3.1";
declare function local:change-user($collection, $user, $group) {
if (xmldb:collection-available($collection)) then
for $child in xmldb:get-child-collections($collection)
let $path := concat($collection, '/', $child)
xmldb:set-collection-permissions($path, $user, $group, 493)
View deploy.xqm
tuurma / move.xquery
Created Nov 23, 2017
move all documents from collection to another
View move.xquery
xquery version "3.1";
for $i in collection('/db/apps/data/a')/*
xmldb:move('/db/apps/data/a', '/db/apps/data/a/b/', util:document-name($i))
tuurma / openIneXide.xq
Created Nov 3, 2017
Open file in eXide link
View openIneXide.xq
tuurma / check.xql
Created Jul 13, 2017
configuration sanity checks
View check.xql
xquery version "3.0";
declare namespace col = "";
(: retrieve all .xconf documents in /db/apps :)
let $dbapps := collection('/db/apps')//col:collection
(: retrieve all /db/apps related .xconf documents in /db/system :)
let $dbsystemapps := for $doc in collection('/db/system/config/db/apps')//col:collection return document-uri(root($doc))
tuurma / update.xql
Last active Mar 7, 2019
XQuery update examples
View update.xql
(: insert attribute :)
for $i in collection('/db/apps/my-data')//nym[not(@cert)]
update insert attribute cert {'high'} into $i
(: insert more than one node :)
update insert (<a/>, <b/>) into //foo
(: make sure to explicitly specify namespaces when inserting/replacing nodes :)
update insert <surname xmlns="">Huo</surname> into //tei:name[.='Otmar']
View gist:8d240c834ac4c6ae48b7c37378e627b3
sm:create-account('shcuser', 'pa$$wd', 'shcusers', '', 'First Last Name', 'SHC project member'),
sm:create-account('tuurma', 'pa$$wd', 'shcusers', '', 'Magdalena Turska', 'SHC project member'),
sm:add-group-member('shcadmins', 'tuurma'),
You can’t perform that action at this time.