XForms is an XML format for the specification of a data processing model for XML data and user interface(s) for the XML data, such as web forms. XForms was designed to be the next generation of HTML / XHTML forms, but is generic enough that it can also be used in a standalone manner or with presentation languages other than XHTML to describe a user interface and a set of common data manipulation tasks.
XForms 1.0 (Third Edition) was published on 29 October 2007. The original XForms specification became an official W3C Recommendation on 14 October 2003, while XForms 1.1, which introduced a number of improvements, reached the same status on 20 October 2009.
Differences from HTML forms
In contrast to the original HTML forms, the creators of XForms have used a model–view–controller approach. The model consists of one or more XForms models describing form data, constraints upon that data, and submissions. The view describes what controls appear in the form, how they are grouped together, and what data they are bound to. CSS can be used to describe a form's appearance.
Like HTML forms, XForms can use various non-XML submission protocols (multipart/form-data, application/x-www-form-urlencoded), but a new feature is that XForms can send data to a server in XML format. XML documents can also be used to prefill data in the form. Because XML is a standard, many tools exist that can parse and modify data upon submission, unlike the case with legacy forms where in general the data needs to be parsed and manipulated on a case by case basis. XForms is itself an XML dialect, and therefore can create and be created from other XML documents using XSLT. Using transformations, XForms can be automatically created from XML schemas, and XForms can be converted to XHTML forms.
At the time of this writing, no widely used web browser supports XForms natively. However, various browser plugins, client-side extensions and server/client solutions exist. The following lists some implementations:
- The Firefox XForms extension was part of the Mozilla Project. XForms 1.0 SE support is not complete but covers most of the specification with a notable exception of attribute-based repeating used in HTML tables. The extension was available for both Firefox 2 and Firefox 3, but is not upgraded to support Firefox 4 and higher. In July 2011 the lead developer wrote that XForms support would no longer get updated. Support for XForms was eventually removed in Firefox 19.
- IBM Lotus Forms supports development and deployment of XForms-based pure XML forms. Trial downloads are available of an Eclipse-based visual design environment and a client-side viewer that can run XForms-based forms both in the web browser and as a standalone desktop application.
- OpenOffice versions 2.0 and greater and LibreOffice support XForms.
Implementation technologies compared
FormFaces, AJAXForms, XSLTForms, betterFORM, Chiba, Orbeon and Smartsite Forms are based on Ajax technology. The amount of server-side and client-side processing varies between these implementations. For example, Ubiquity XForms, FormFaces and XSLTForms provide 100% XForms client-side processing and data model updates via pure Ajax processing on the XForms standard. The others use server-side Java/.NET XForms processing transcoding to Ajax markup prior to delivering the content to the browser. Both techniques can work across browsers. Each implementation is significantly different with respect to dependencies, scalability, performance, licensing, maturity, network traffic, offline capability, and cross browser compatibility. System architects should evaluate these constraints against their need to determine potential risks and objectives.
Plugins like FormsPlayer and other client-side technology can have some benefits as well: because they integrate themselves into the browser, they will work with existing server architectures, can be more responsive, and require fewer server fetches.
The tradeoff between server-side and client plug-in solutions is where the software is maintained; either each client must install the required plug-in, or the server architecture must change to accommodate the XForms transcoder engine language technology. It is in theory possible to mix both of these solutions, for instance testing the browser for a client-side XForms implementation and serving native XForms in that case, and defaulting to a server solution in other cases.
Ubiquity XForms, FormFaces and XSLTForms provide a "zero software" solution on either the client or server: no new software needs to be installed on the client and the solution can be used in conjunction with any server-side architecture. This is possible because FormFaces and Ubiquity XForms are written 100% in Ajax and because XSLTForms is written in XSLT and in Ajax. The tradeoff is that compared to other solutions, more code is initially downloaded to the client (code can be cached on the client), and FormFaces does not yet support XML Schema validation. Furthermore, XForms submissions with replace "all" behaviour will typically not result in true page replacements and therefore break the normal back button behaviour.
XRX application architecture
Because XForms makes it easy to edit complex XML data there are many advantages to using XForms with native XML databases that frequently leverage REST interfaces. The combination of three technologies (XForms on the client, REST interfaces and XQuery on the server) is collectively known as XRX application development. XRX is known for its simple architecture that uses XML both on the client and in the database and avoids the transformations to object or relational data structures. See "XRX:Simple, Elegant, Disruptive".
XForms for mobile devices
XForms provides specific benefits when used on mobile devices:
- User interfaces using XForms require fewer round trips with the server and are in that sense more self-contained than user interfaces using HTML 4 forms.
- Capabilities of mobile devices vary greatly; consequently the amount of the work involved in generating different user interfaces for different devices is of particular concern in the mobile world. XForms has been designed from the ground up to allow forms to be described independently of the device, which reduces the amount of work required to target multiple devices.
Xfolite is a light-weight XForms client for the J2ME platform. It was originally created at Nokia Research Center, and it includes a DOM and XPath 1.0 implementation as well as an XForms engine that implements the XForms 1.1 specification almost completely. XFolite is currently in beta and should not be considered ready for production use. The first real world implementation has been in the Nokia Data Gathering mobile client . XML Schemas and CSS are outside project scope, however. Xfolite is open source and licensed under the LGPL license.
JavaRosa is an XForms client written in Java Mobile Edition (J2ME), and supports a wide array of devices, from top-end smart phones and PDAs with large screens and abundant memory, to low-end devices like the Nokia 6085 and 2630. Making JavaRosa usable on low-resource devices is one of the project's highest priorities. JavaRosa 1.0 Alpha was released in September 2010.
ODKCollect is part of the Open Data Kit, and is an XForms client for Android devices. The client displays XForm in sequential order obeying form logic, entry constraints, and repeating sub-structures. Users work through the prompts and save the submission as completed or partially completed (allowing later revision), and can record pictures as well as their location using the phone's built-in camera and GPS device, respectively.
Group Complete is a mobile data collection system that includes Group Complete Mobile (GC Mobile), an XForms client for Android devices. GC Mobile provides an interface to create XForms on the mobile device as well as XForms data entry with capabilities similar to ODKCollect. Forms and data are stored in CouchDB databases allowing mobile workers to make changes to forms and data while offline, collaborate on data entry and share collected data with team members and backoffice data consumers in real-time. Group Complete is compatible with all major ODK systems. Group Complete was discontinued as of March 2012  and the code released in February 2013 as open source.
- Mozilla: Mozilla XForms Project - Download. Accessed 2013-03-12.
- Philipp Wagner: The Future of Mozilla XForms, 13 July 2011
- Mozilla Developer Network (MDN): XForms. Accessed 2013-03-12.
- Apache OpenOffice: User Manual/Writer Guide/XForms. Accessed 2013-03-12.
- The Document Foundation: XML Form Documents (XForms). Accessed 2013-03-12.
- Group Complete website announcement, 03/2012
- Group Complete blog announcement, 02/2013
- XForms 1.1 - W3C Recommendation 20 October 2009.
- Raman, T.V. (2004). XForms: XML Powered Web Forms. Boston: Addison-Wesley. ISBN 0-321-15499-1.
- Dubinko, Micah (2003). XForms Essentials. Sebastopol, CA; Farnham: O'Reilly & Associates. ISBN 0-596-00369-2.
|Wikibooks has a book on the topic of: XForms|
- XForms Resources at W3C
- The Forms Working Group
- The XForms Users Community Group
- XForms 1.0 Frequently Asked Questions
- XForms 1.1 was a W3C Recommendation on 20 October 2009
- XForms 2.0 Working Draft
- XForms 1.0 (Third Edition) was a W3C Recommendation on 29 October 2007
- A quick introduction to XForms for HTML Authors by Steven Pemberton
- XForms Quick Reference
- XForms Implementations
- XML:Forms at the Open Directory Project
- Smartsite XForms