XRX/Save File Dialog

Motivation
You want to allow the user to save form data into a named file in an eXist collection that will not conflict with existing files.

Method
When the user selects a Save button we will use switch/case to open up a save dialogue. In this dialogue we will list all of the current files in a collection and allow the user to create a new file with a name that does not conflict with any existing file names. If the user selects a file from the list, we will replace the current file name with that file name.

Using the get-child-resources Function
eXist provides a function that lists the files in a collection. You can get a sorted list of all the files in a collection with the following XQuery

When executed, this XQuery will return the files in a collection. For example here is the URL of an XQuery execution with the collection parameter passed as an argument:

list-files-in-collection.xq?collection=/db/rss

We can then use this XML listing to display a list of existing files and allow the user to select a name that is not on this list.

Sample Program
 

Discussion
Back: Move a Resource • Next: Login and Session Management