Skip to content

Instantly share code, notes, and snippets.

@joewiz
Created October 30, 2013 22:02
Show Gist options
  • Save joewiz/7241131 to your computer and use it in GitHub Desktop.
Save joewiz/7241131 to your computer and use it in GitHub Desktop.
Save a collection of XML documents from eXist-db onto the file system, with XQuery
xquery version "3.0";
let $file-system-target-base-directory :=
(: Mac :)
(: '/Users/Joe/workspace/paho-trunk' :)
(: Windows :)
'C:\Users\wicentowskijc\oxygensvn\paho-trunk'
let $source-collection := '/db/cms/apps/tei-content/data/short-history'
for $doc in collection($source-collection)
let $target :=
(: Put the files into a corresponding directory in the file system :)
concat($file-system-target-base-directory, replace(base-uri($doc), '/', '\\'))
return
file:serialize($doc, $target, ("omit-xml-declaration=yes", "indent=yes"))
@joewiz
Copy link
Author

joewiz commented Jan 23, 2017

@OleksiL Sorry I didn't see your comment until now - GitHub doesn't send notifications when users leave comments in Gist. 👎 If you're still having this problem, please post your question to exist-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment