In the early ’90s, the concept of data capture forms was added to the HTML language specification. HTML forms enable Web developers to create Web pages that solicit and capture information via the Web browser.

Users enter data into the form using form elements, or “controls.” Common examples of form elements include text boxes, drop-down lists, radio buttons, and check box elements. Data submitted through forms is processed by the Web server under the control of the form action attribute. Using this mechanism, organizations worldwide have developed complex, Web-based e-commerce applications processing millions of transactions daily.

Although Web forms have been the mainstay for capturing data over the Web for several years, today’s e-commerce applications require more flexibility. The standard Web browser is no longer the only choice for accessing Web pages. Users can now browse the Web from PDAs, phones, interactive television, and other devices. Efforts are also in the works to control and interface with electronic equipment.

Attentive to these needs, the members of the W3C’s XForms Working Group are redefining forms to support a wider range of requirements. XForms is the manifestation of this reformulation of the Web form concept. Let’s take a quick look at the role of XHTML in redefining form elements. Then, we’ll focus on how XForms will enable you to develop a more platform-independent solution.

Making form elements look like XML
XHTML redefines the syntax of form elements to adhere to the more universally recognized format provided by the XML rules. The XHTML document type definition relating to forms (the Forms Module) includes all the features found in HTML 4.0. For a complete list of what the Forms Module supports, including its attributes and minimal content model, check out the W3C’s Web site.

While XHTML redefines form controls as XML elements with specific attributes, the presentation of these elements is still closely tied to their definition. For example, you may find the following code in a simple XHTML document:
<form action= method=”post”>
<input type=”radio” name=”test” value=”test element 1”>test element 1</input>

As you can see, the presentation of the element is included within the definition (type=”radio”). While this isn’t an issue on simple Web screens, today’s e-commerce requirements are more complex. For example, a data capture form for an inventory control application may be viewed on a PC, handheld device, or cell phone. With presentation tightly coupled with the data, developers need to create three screens to collect this information. This is where XForms comes in.

Separating function from presentation
XForms is a Web form specification consisting of separate sections that distinguish the purpose or functionality of the form from the presentation.This allows flexible presentation options to be incorporated into page design. XForms is currently a W3C working draft, designed to deliver the following:

  • Support for multiple hardware types, such as handhelds, television, PC, printers, and scanners
  • A rich user interface to meet the needs of business requirements
  • Separation of presentation from data
  • Support for structured form data
  • Internationalization support
  • Multiple forms per page
  • Advanced forms logic
  • XML tag set support

Here’s a quick overview of how XForms will accomplish this.

The three parts of a form
The main goal of XForms is the separation of the three elements of a form: presentation, data capture, and submission. Each element has an independent definition. In other words, you can define a form separately from how it appears on the end user’s browser. This allows you to use the same data capture definition with disparate presentation definitions.

What does this mean? You can use a single data capture definition with standard HTML to present the form on a Web page, and you can use the same data capture definition with Wireless Markup Language (WML) to capture data from a cell phone or wireless device. The independent section that defines the XML form data capture elements is the XForms Model, and it’s the first W3C working draft submission.

An important concept in the XForms Model is that forms collect data that’s represented as XML instance data. According to the XForms Model, the data’s structure enables structured data interchange as in standard XML interfaces.

The XForms Working Group also proposes that the XForms Model include logic elements for the verification or validation of captured data. To do this, the XForms Model includes predefined data structures, data types, data attributes, and validation attributes.

Presentation is provided by means of a standard definition called the XForms User Interface. This definition contains a set of visual controls aimed at replacing those currently found in XHTML. You can use other presentation choices, too, including WML, XHTML elements, and proprietary schemes. XForms also includes a Submit Protocol for sending and receiving the XML instance data captured by the form.

Although XForms is in its early stages, it will provide a much-needed boost to the capability of standard Web pages. For more information about the development of XForms, check out the W3C’s XForms Web page.

Do your forms need to run on multiple platforms?

Do you develop for devices other than your run-of-the-mill PC? Tell us about the challenges you face when coding for PDAs, phones, or other devices. Send us an e-mail with your experiences and suggestions or post a comment below.