Getting Data into eXist-db

(2Q19)


eXist-db is a document oriented database and therefore stores documents. But how do you get them in? This article will handle several ways of doing that.

Uploading files using the Dashboard

eXist-db's Dashboard's comes with a Collections pane. This lets you upload files from your filesystem into the database. Click on this icon to open it iIf you are not logged in, Dashboard will prompt you to log in first):

The Collection pane's icon
The Collection pane's icon

A dialog will appear showing you the database collection hierarchy. After that perform the following steps:

  1. Select the target collection for your files in the left pane.

    If you need to create a new collection for your files first, do so by selecting the New Collection button; it looks like a manila folder with a green plus.

  2. Click on the Upload button (it looks like a gray cylinder with a green plus).

  3. Either drag and drop the files you want to upload or browse to select a file from your disk.

Uploading files with eXide

eXide is eXist-db's built-in Integrated Development Environment (IDE). Among eXide's many functions is the ability to upload files from your filesystem into the database.

To initiate an upload:

  1. Open eXide from the Dashboard

  2. Choose File, Manage from the menu

  3. click on the Upload button.

  4. Either drag and drop the files you want to upload or browse to select a file from your disk.

Uploading files with a WebDAV client

A WebDAV client lets you manage eXist-db database collections and documents almost like directories and files in a filesystem. WebDAV clients, or applications with built-in WebDAV support, include Windows Explorer, macOS Finder, cadaver, KDE Konqueror, oXygen XML Editor, XML Spy, LibreOffice, Transmit (MacOS only), and many others.

To connect a WebDAV client to eXist-db, you need the URL for eXist's WebDAV interface and an eXist-db username and password. eXist-db's default URL for its WebDAV interface is:

http://localhost:8080/exist/webdav/db/

The URL with HTTPS (SSL) encryption (some clients, among which Windows Explorer, require such a connection) is:

https://localhost:8443/exist/webdav/db/

The client may accept a URL or it may ask you to split up the URL into its component parts. Taking http://localhost:8080/exist/webdav/db/ as an example, the server name is localhost, the port is 8080, and the remote path is /exist/webdav/db.

Dedicated WebDAV clients are an excellent way to upload and manage the contents of their database. For more information about using WebDAV connections with eXist-db (including client-specific instructions), see the WebDAV article.

Uploading files with the Java Admin Client

The Java Admin Client also lets you upload files into the database. This can be done using the GUI or the command line.

For uploading files using the Java Admin Client's GUI:

  1. Start the Java Admin Client, for instance by selecting the Open Java Admin Client command from eXist-db system tray application's menu.

  2. Select File, Store files/directories, or click on the Store icon (which looks like a piece of paper with a plus icon).

  3. Select the file(s) you want to store in the database

To upload files with the command line:

bin/client.sh -m /db/path/in/database -p /path/on/file/system

The -m parameter specifies the target collection, the -p parameter the path on the filesystem to the files to upload. See also the Java Admin Client documentation.

Uploading files with XQuery

Of course you can also programmaticly store documents in the database files using eXist-db's main programming language XQuery. For this use the xmldb:store() function. Fetching the documents (or data) to store can be done using the various HTTP Client modules, such as the EXPath HTTP Client http:request() function or the eXist-db specific httpclient:get() function. You can also fetch your data from the filesystem using xmldb:store-files-from-pattern(), which accepts wildcard patterns like *.xml.

Uploading files with Ant

Ant is a build tool for automating common tasks. eXist-db comes with some special Ant eXist-db actions to automate things like importing or exporting files, etc.

The action for uploading files and storing them into your database is xdb:store. See Ant Tasks for more information.