Skip to content

Instantly share code, notes, and snippets.

@joewiz
Created October 30, 2013 22:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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"))
@OleksiL
Copy link

OleksiL commented Jul 4, 2016

Hi Joe.
I've been looking on the internet how to save non xml file from exist db to local disk through browser's Save File dialog and found your example.
If you have a time maybe you could look at this and tell me what is wrong with it?

<xf:trigger appearance="xxforms:download">
 <xf:label>log link</xf:label>
 <xf:action ev:event="DOMActivate">
  <xf:load show="new">
   <xf:resource value="logLink"/>
  </xf:load>
 </xf:action>
</xf:trigger>
<logLink>
    {concat(request:get-scheme(), "://", request:get-server-name(),":", '8080', '/exist/rest/db/zips/Report4.7z')} 
</logLink>

I do not get save file dialog and browser tries to open the file as XML which it obviously can't do.

@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