Skip to content

Instantly share code, notes, and snippets.

@tuurma
Created July 13, 2017 09:49
Show Gist options
  • Save tuurma/0677f495168556a5644dfa9394d9a91d to your computer and use it in GitHub Desktop.
Save tuurma/0677f495168556a5644dfa9394d9a91d to your computer and use it in GitHub Desktop.
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))
(: find all .xconf documents in /db/apps that do not have an direct equivalent in /db/system,
: or one in subcollection named after that xconf :)
for $app in $dbapps
let $d:= document-uri(root($app))
let $cpath := util:collection-name($app)
let $scol := '/db/system/config' || $cpath || '/' || util:document-name($app)
return
if ( ('/db/system/config' || $d) = $dbsystemapps) then ()
else if(doc-available('/db/system/config' || $cpath|| '/' || substring-before(util:document-name($app), '.xconf') || '/' || util:document-name($app))) then ()
else $d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment