Steven PembertonImage via Wikipedia
“XForms and Declarative Applications” – Steven Pemberton
HTML Forms are a great success, the basis of the e-commerce revolution etc. but unanticipated at the time.
After more than a decade of experience time to move on, move away from the misconception of HTML as a presentation language. More abstraction is needed for advanced purposes. Compare presentational HTML to the Zen Garden approach of basic HTML and rich CSS.
- Ease of authoring
- Good user experience
- Ease of changing
- Device independence (mobile platforms anyone?)
The essence of XForms
Complete separation of Date from Content: Instances and Controls
The instance specifies the values being collected. Datatypes specify client side validation and constraints for values entered, even more complex logic like state is only required if county equals USA. Submission actions define the target for the data and what should be done with the result. Together this forms the model, the datasheet.
Abstract or intent-based controls. These are bound to the data (values). Syntax is simply binding an input control to a data item, by which the input knows what data type should be expected and the correct control is chosen. E.g. input for birthdate, whre birthdata is of type date, renders a calendar input popup.
The default XForms give you a toolbox which is very similar to a spreadsheet, no programming needed for common use cases. The actual XForms definition consist of standard XML and the data / values are transferred as XML as well.
Any XML data can be bound to a control, so there’s nothing which prevents editing a xhtml document (as instance) by using XForms syntax. Any page element can be bound by using XPath. Only restrictions: the page must be well-formed xhtml and the server must accept PUT or POST in order to update the page.
Other nice features include:
- i18n for all form elemens, including labels.
- auto-complete on form fields (demoed with live google translate per word, as you type.
- live search: flickr images
- geo-location as pair of lat/long or a map, bound to the same resource and so updating each other on change.
Implementations vary from plugins (for msie) and native (mozilla). Big vendors use XForms as part of their CMS and Application servers already. Most of this is not user visible, you just experience a rich user interface in the browser.
Current browser support is still limited, but the ubiquity-xforms library aims at extending existing Ajax libraries to add XForms support for a broad range of browsers.