You can include XML instances (XForms or XML Data Model) in your Web page that contain XML data that you can move into your form. This XML data can replace or add to existing XML data inside your form – particularly useful for dynamically populating forms with information selected by the user from an HTML page.
For example, consider a purchase order form embedded in an HTML page. The XFDL form is a generic purchase order form, possibly personalized with user information via a data fragment. This form is displayed in an HTML page (or a series of HTML pages) that allow users to select the products they want to purchase. When users select the desired product, they trigger the application server to create a custom XML instance to replace the generic XML instance currently in the XFDL form. To the eyes of the users, the form appears to automatically populate with the correct purchase information, including order number, product type, and pricing.
Regardless of whether the XML instance is hardcoded into the HTML page or generated by an application server, it must be wrapped in a script container. Like a script element containing an XFDL form, you must define the following attributes:
This value must always be XFDL
. For example:
Identifies the instance. This id must match the instance value in the parameter of the object element that contains the form. For example, if the instance value of instance_1 is as below:
<OBJECT ... object attributes ...>
append [custom:record] [custom:name]">
... other params ...
then your script id must be:
attribute has two parameters:
- mime type — This value must always be application/vnd.xfdl.
- wrapped — Identifies the type of container that encloses the instance. This value must always be comment.
- encoding — The encoding of the instance embedded in the script element. For example, if the instance is base64 encoded, then the value is base64.
<SCRIPT type="application/vnd.xfdl; wrapped=comment">
The type and wrapped parameters must be separated with a semi-colon.
To identify XForms instances, you must add an xforms;
parameter to the form object. For more information, see Defining the object parameters
To embed an instance:
- Create a new script element. For example:
<SCRIPT id=new_Instance type="application/vnd.xfdl; wrapped=comment">
- Place a comment wrapper between the script tags.
- Paste the XML instance between the comment tags.
The following example depicts a script element that contains an XML instance enclosed in a comment wrapper:
<SCRIPT id="new_Instance" type="application/vnd.xfdl; wrapped=comment">
Order of precedenceParent topic: Embedding a form
Forms often include multiple XML instances. They may even refer to data fragments
, frequently used scraps of XML data that are stored on users’ computers. If your HTML contains replacement instances, or if replacement instances are generated by an application server, the Viewer must follow an order of precedence to ensure the instances are always loaded in a consistent manner.