Tuesday, February 14, 2012

Does XForms need to be implemented natively in browsers?

For as far as we can remember, we've been getting variants of the following question: "Does XForms, as a technology, really have a future? I wonder, as I don't see browsers making any moves to implement it."

When considering technologies, it is reasonable to worry about their future. But why would one think XForms has no future if it isn't implemented in browsers?

In the late 90s and early 2000s, XML technologies were widely imagined to be the foundation on which future web apps would rely. As part of that vision, browser vendors implemented XML parsing, XPath, XSLT transformations, and even CSS styling of XML documents. XForms too was initially designed to nicely fit in that stack.

For better or for worse, that XML-centric vision didn't come to fruition. This in particular means that initial efforts to bring XForms to the browser natively have been abandoned. Instead today's browsers mostly eschew XML and implement improved, faster and more robust versions of the technology stack we had 10 years ago: HTML, CSS, the DOM and other JavaScript APIs, and of course JavaScript itself.

In short, in the browser, JavaScript has won and XML has lost, as part of the native browser stack. It might be disappointing to some, but at Orbeon, we recognized this many years ago. In 2005 already we implemented the first version of our Ajax-based XForms engine, which shipped in Orbeon PresentationServer 3.0.

So the native XForms ship has sailed a long time ago in our opinion. Instead, the web browser has increasingly shown to be a great platform to build all sorts of application and frameworks, and XForms happens to be just one such technology.

This situation in fact has great benefits: nobody waits for browser vendors or all web users to upgrade their browsers to use a newer version of jQuery or Ruby on Rails. So not being a native browser technology allows us to move faster, and you to benefit from improvements sooner (proof: the Orbeon Forms engine still works in IE 6!). It also allows Orbeon to implement a split architecture, where data can reside on the server, while logic run on either the browser or the server, depending on what is the most appropriate.

And what about HTML5 forms? Do HTML5 forms mean that XForms is no longer needed? HTML5 contains welcome incremental improvements over what is available in HTML 4: if you are creating very simple forms, HTML forms and a bit of JavaScript will be just fine. Where XForms has a big edge is for creating complex forms, maybe with sophisticated validation logic, or to manage a large number of forms. And needless to say, if you already deal with XML data, XForms will be a perfect match.


  1. Hi Alex,

    I see being a new dad certainly makes you worry about your other "kids".

    Joke aside, I also started developing major applications based on XML abstractions in 1999 and I still believe this approach to be a very valid one, as it allows to separate structure and content from other layers, such as presentation, which is the real focus of web browsers (to present information, in any way we see fit).

    As you rightly describe, having an intermediate layer between your content and structure and the final presentation layer allows us to be more agile in adapting either side to any desired or required modifications, either to follow developments made in a dependency or to implement new and shinier features within your own realm.

    XForms remains a niche, as many other XML languages/schemas (MathML comes to mind), but a very useful one in it's own domain. Given enough exposure, it might even, one day, blossom. But until then, keep on nuturing it, as it's fruits may still be to bare.

  2. I believe that HTML5 and XForms make a great combination in modern desktop and mobile browsers. HTML5 shys away from declarative programming, providing an "assembly language" base of JavaScript interfaces and DOM event interfaces, on which many other, higher-level approaches can be built. XForms is an MVC-based, declarative system that can leverage the underlying HTML5 features just as other JavaScript or server-side technologies do. So while the benefits of XForms stand on their own, they don't prevent you from making use of the HTML5 native features. For example, Orbeon pioneered the use of "placeholders" as display of the XForms "hint", seamlessly using either HTML5 or a JavaScript+HTML5 implementation, and delivering a consisten, easily-to-write experience to the form author.