Implementing Xforms on Your Site
Introduction
Because they're the primary means of communication between a web site and its users, HTML forms are an important part of a web site. The next stage of development of HTML forms is a fairly new standard named XForms, "...a new platform-independent markup language for online interaction between an XForms processor and a remote entity."1
HTML forms have many limitations. Currently there is no relationship between HTML forms and XML. HTML forms are device-dependent, not supporting screens of small and very large sizes. There is a mixture of purpose and presentation that is difficult to manage if a different look-and-feel is required, and there is a limited accessibility of features. As the W3C states:
The current design of web forms doesn't separate the purpose from the presentation of a form. XForms, in contrast, are comprised of separate sections that describe what the form does, and how the form looks. This allows for flexible presentation options, including classic XHTML forms, to be attached to an XML form definition.
XForms is planned to be a part of the XHTML 2.0 specification.
NOTE
The primary source for information on XForms is the www-forms mailing list. To subscribe, send an email to www-forms@w3.org with the word subscribe in the subject line (include the word unsubscribe if you want to unsubscribe).
The XForms Model
The first important concept in XForms is the XForms model, a single device-independent XML form definition that can be plugged into various presentation options, including XHTML, WML, or other proprietary user interfaces. Following is a sample XForms model:
<model xmlns="http://www.w3.org/2001/12/xforms" id="Person"> <instance xlink:href="http://example.com/cgi-bin/get-instance" /> <schema xlink:href="Schema-Questionnaire.xsd" /> ... </model>
The XForms User Interface
The second concept is that of the XForms user interface, which provides a standard set of visual controls that are targeted toward replacing today's XHTML form controls. These form controls are directly usable inside XHTML and other XML documents.
XML Instance Data
The third concept is that forms collect data, which is expressed as XML instance data. The XForms model describes the structure of the instance data. Forms normally represent a structured interchange of data, while workflow, auto-fill, and pre-fill form applications are supported through the use of instance data.
Here is an example of an <instance> element:
<model> <instance> <my:lines> <my:line name="a"> <my:price>5.00</my:price> </my:line> <my:line name="b"> <my:price>31.28</my:price> </my:line> <my:line name="c"> <my:price>111.99</my:price> </my:line> <my:line name="d"> <my:price>0.14</my:price> </my:line> </my:lines> </instance> </model>
The XForms Submit Protocol
The fourth concept is the need to have a channel for instance data to flow to and from the XForms processor. To accomplish this, the XForms submit protocol defines how XForms send and receive data, including the ability to suspend and resume the completion of a form.