Skip to content

Instantly share code, notes, and snippets.

@claudius108
Created November 27, 2020 08:14
Show Gist options
  • Save claudius108/44e26ec506e2a0772f9079b1b67ea5d8 to your computer and use it in GitHub Desktop.
Save claudius108/44e26ec506e2a0772f9079b1b67ea5d8 to your computer and use it in GitHub Desktop.
local:create-collections-recursively()
declare function local:create-collections-recursively($target-collection-uri as xs:string, $new-collection-path-steps as xs:string*) as xs:string* {
if (exists($new-collection-path-steps))
then
let $new-collection-name := $new-collection-path-steps[1]
let $new-collection-uri := $target-collection-uri || "/" || $new-collection-name
return (
if (not(xmldb:collection-available($new-collection-uri)))
then xmldb:create-collection($target-collection-uri, $new-collection-name)
else ()
,
local:create-collections-recursively($new-collection-uri, subsequence($new-collection-path-steps, 2))
)
else ()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment