Skip to content

Instantly share code, notes, and snippets.

View tuurma's full-sized avatar

Magdalena Turska tuurma

  • eXist solutions
  • United Kingdom
View GitHub Profile
@tuurma
tuurma / remove.xql
Created July 5, 2017 09:58
remove all documents in a collection
xquery version "3.1";
for $i in collection('/db/apps/temp')/*
return
xmldb:remove('/db/apps/temp', util:document-name($i))
repo:install-and-deploy('http://www.tei-c.org/tei-simple', 'http://demo.exist-db.org/exist/apps/public-repo/modules/find.xql')
file:sync("/db/apps/lgpn", "C:\Users\Magdalena\Documents\GitHub\LGPN", ())
@tuurma
tuurma / gist:7e20dc0dfcb5a3afcfa408a3897282b1
Created July 5, 2017 12:52
repair app package registration
xquery version "3.0";
import module namespace repair="http://exist-db.org/xquery/repo/repair"
at "resource:org/exist/xquery/modules/expathrepo/repair.xql";
repair:clean-all(),
repair:repair()
sm:create-group('shcusers')),
sm:create-group('shcadmins')),
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'),
sm:remove-account('tuurma')
@tuurma
tuurma / update.xql
Last active March 7, 2019 09:58
XQuery update examples
(: insert attribute :)
for $i in collection('/db/apps/my-data')//nym[not(@cert)]
return
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="http://www.tei-c.org/ns/1.0">Huo</surname> into //tei:name[.='Otmar']
@tuurma
tuurma / check.xql
Created July 13, 2017 09:49
configuration sanity checks
xquery version "3.0";
declare namespace col = "http://exist-db.org/collection-config/1.0";
(: 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
tuurma / openIneXide.xq
Created November 3, 2017 12:33
Open file in eXide link
http://localhost:8080/exist/apps/eXide/index.html?open=/db/apps/data/names/Agaios.xml
@tuurma
tuurma / move.xquery
Created November 23, 2017 20:46
move all documents from collection to another
xquery version "3.1";
for $i in collection('/db/apps/data/a')/*
return
xmldb:move('/db/apps/data/a', '/db/apps/data/a/b/', util:document-name($i))
repo:undeploy("http://history.state.gov/ns/site/hsg"),
repo:remove("http://history.state.gov/ns/site/hsg"),
repo:install-and-deploy-from-db("/db/system/repo/hsg-shell-0.2.xar")