XForms/Application Builder

Motivation
You want to create a form that captures the specifications of an application that manages data saved from a form.

Method
Many times the resources needed to create an application are very similar. Many applications need basic operations such as:


 * 1) Create a New Record
 * 2) Read (view) a Record
 * 3) Update a Record
 * 4) Delete a Record
 * 5) Search for Records

These applications (sometimes referred to as a CRUD application for Create, Read, Update, Delete) are created over and over and frequently a pattern emerges. This pattern can be used as the basis for a specification and we can then build an XForms application to capture that specification.

This example assumes that the user wants to do these operations on a simple form and guides the user through a series of questions. A series of defaults is assumed but the user is allowed to override these defaults when the requirements differ from the standard.

The phrase "convention over configuration" is frequently used to describe a series of built-in assumptions about the default behavior of an application. If the developer of the application knows these conventions a highly functional initial application can quickly be created.

This form starts asking a series of questions, some of which are input fields, some check boxes and some text descriptions. Some input fields are referenced later in the application using binding rules. These binding rules are the conventional behavior of the application.

After the application specification is complete a "Generate Application" function can be executed. This will take the application specification file and execute a series of scripts on the server. Here are a sample of some actions that can be taken by these server-side build scripts. In this example we are using terminology from native XML data stores with XQuery REST interfaces but there are similar actions for RDBMS stores


 * 1) Create Default Collections
 * 2) data collection for XForms instance data
 * 3) edit collection for XForms editors (any forms that lock resources
 * 4) views collection for storing read-only views
 * 5) search collection for searching form instance data
 * 6) schemas collection for XML Schemas
 * 7) Create Application Template Files
 * 8) edit.xq - XForms editor for new records and updating records (generated form the XML Schema)
 * 9) new-instance.xml - default data for a new record
 * 10) search-fomn.xq - Generates an XForms application for searching
 * 11) search.xq - XQuery for searching records - return an HTML results page
 * 12) list-items.xq - A one-line summary of each XForms instance
 * 13) view-item.xq - A one-line summary of each XForms instance

As you can see the actions are the creation of server-side collections and files that are parameterized by the form instance.

Similarities to Ant Build Scripts
The application builder server-side script is similar to Apache build scripts in several ways. With Ant a series of folders and files are created when a build script is executed.