Chapter 4. Building the base scenario: Stage 1 105
This block of XML allows for arbitrary data, meaning that it can contain any data and can be
formatted in any manner. Furthermore, individual elements in the data model can be bound to
one or more elements in the form description. This binding causes the elements to share
data. If one element is changed, the other elements are updated to mirror that change.
This allows you to create a separate block of data within the form, format it any way you like,
and bind it to form elements so that data entered by the user is automatically copied to the
data model. For example, you could include the block of data that is required by an application
(such as an IBM Content Manager based system), format the data so that it complies with a
specific schema, and then bind that data model to the form description.
The result is a block of XML data that can be structured to meet any needs, extracted easily
by other applications, and transmitted without the rest of the form.
4.7.2 Creating XML bindings
Once you have created a data instance, you need to bind the data elements. A bind creates a
link between two elements in the form. This link causes those elements to share information,
meaning that if one of the elements is changed, the other element is updated to mirror that
change.
There are two types of binds:
Data element to form element:
In this case, one element in the data instance is bound to one option in the form
description. This type of bind links your data model to the form description, so that
information entered by the user is copied to your data model. For example, you might
create a bind that links the firstName element in your data instance to the
firstNameField.value option in your form description.
Data element to data element:
In this case, one element in the data instance is bound to another element in the data
model. This type of bind is often used to perform special calculations or to copy
information from one part of the data model to another. For example, you might have a
data holder element that performs a calculation. You could then bind this element to copy
the result of the calculation into your data instance.
Each bind creates a one-to-one relationship: one data element to one data or form element.
However, you can also create a one-to-many relationship — one data element to many data
or form elements — by creating additional binds. For example, you could bind the firstName
data element to both the firstName field on page one of the form and the firstName field on
page two of the form. All of the bindings are contained within a <bindings> tag in the data
model, as shown:bind a form element to more than one data element.
An XML binding is a way of linking the fields on your form to the XML instance that describes
the captured data.
The following steps describe how to use the XML Data dialog to create your XML bindings:
1. Open the XML Data Model dialog from the toolbar, Tools → XML Data Model →
Create/Edit Manually, and click the Bindings tab.
2. Click the button that looks like a file menu and then select a data element from the XML
instance.
3. Click the button with the hand icon; the workspace will be brought to the front. Select the
corresponding field.
4. Click the Add button to add the binding to the list.