The "XForms Myth" Myth
Hixie says on his blog, XForms myths:
I'm getting tired of hearing XForms advocates say things that are either misleading or clearly wrong, so here's a quick list of myths, or misleading truths, about XForms, which I have heard recently (most particularly during the multiple demos of XForms software at the plenary in Boston last week).
First let's set the scene; by "in Boston last week", Hixie means the W3C Technical Plenary where all the W3C Working Groups get together for a week. The middle day is usually given over to discussions and demos ... Lots of thought-provoking stuff.
The "multiple demos of XForms software" actually amounted to only two demos (perhaps it just felt like we were taking over, since I was also on a panel discussing the future of web applications, whilst Steven Pemberton, the chair of the XForms and HTML Working Groups, presented arguments for why we needed XForms rather than just tinkering with HTML).
The first demo was by me, in a section of what are called 'lightning talks' -- you get three minutes to talk about anything you like, and then the audience gets two minutes to ask you questions. It's a great format, and means that with good chairing (which Paul Downey ruthlessly provided!) you can squeeze 10 or so interesting topics into an hour. With my three minutes I demonstrated formsPlayer 2.0, with SVG widgets that sit on top of XForms, wired in using XBL.
The second of the 'multiple XForms demos' was in a different session, where the panel discussed voice-based systems. Mikko Honkala from the University of Helsinki showed X-Smiles running an XForm that allowed him to interact using speech. I don't think the audience quite appreciated the power of what they were seeing -- perhaps because Mikko's presentation did not look as polished as those from the multinational companies he was seated alongside -- but the form he was using to capture the voice data was exactly the same form that was used to capture keyboard input. In other words, XForms was showing its truly platform-independent nature.
So now you have the back-drop to Hixie's comments, let's go through his 'myths' one by one.
XForms is declarative
XForms is declarative
XForms has declarative aspects, just like HTML. But it isn't exclusively declarative. XForms in fact introduces a primitive XML-based scripting language (called XForms Actions) to perform imperative actions.
For example, you can use the setfocus element to set the focus to another element, or the load element to make the UA follow a link.
No-one said that XForms was exclusively declarative, and we certainly don't fall into the Microsoft XAML trap of saying that something is declarative just because it uses XML instead of code. So in that sense Hixie is right to point out that just using XML elements to define your actions does not make your language declarative.
But Hixie wins no points for saying that the non-declarative aspects of XForms are not declarative -- what he should really address is the truly declarative aspects of XForms, and say why he objects to them and would rather use spaghetti JavaScript in an attempt to achieve the same ends.
For example, in XForms we can indicate the range of possible values for a piece of data. We might say that the value must be a temperature above freezing. In the 'normal' programming model you achieve this functionality by checking at various points to see if the value entered is indeed above zero (and of course whether it is even a number at all). In an HTML form you might perform this check when the user changes the data, or just before you save the data to the server.
The key point is that how you do the checking is extremely likely to be different from how I do it, and when you do it will again be different from me. We can be pretty sure that we both used JavaScript since there is no other way to do it in HTML -- although we could have delegated the checking to the server -- but more than that we can't say. And if a machine looked at our HTML pages it would have trouble working out exactly which bit of script does the checking and when, since it would need to understand what the script was doing. (Try looking at the source for Google's Gmail or mapping site, and imagine writing an automated process that 'understands' what the code is doing.)
XForms provides a 'declarative' way to do this because it allows us to do everything that the HTML form can do, by doing nothing more than indicating what 'type' the data is. An XForms processor then takes care of the rest, including:
- sending notification events when the data changes from valid to invalid, or vice versa;
- changing the CSS to reflect the valid and invalid states;
- rendering alert messages when the data goes invalid.
And note that it does this automatically, as the data changes, interacting with all controls that are using this piece of data, something that gets very complicated in JavaScript when you get more than a couple of controls. But note also that XForms defines clearly when things happen, such as when the data is validated. This makes it much easier to write interoperable forms (forms that will run on many different XForms processors), since the flow is clearly defined in the spec.
In this example XForms is truly declarative, since we have not defined the 'how' of what we want doing, instead simply stating what it is we want to achieve.
Scripting is bad for accessibility
Scripting is bad for accessibility
False. Scripting doesn't hurt accessibility. What hurts accessibility is when semantically meaningless elements are given some sort of device-specific behaviour (for example, making a div into a checkbox or a scrollbar, or using the font element for headers).
I don't know anyone that doesn't think that scripting is almost completely useless for creating accessible applications. It is almost impossible to know which part of the script in a page is responsible for hints and captions, which therefore makes it difficult for voice systems to know what to read to a blind user, and when.
Script is harder to maintain than XPath expressions
Script is harder to maintain than XPath expressions
False. It depends entirely on what you're doing. The reason most JavaScript on the Web is a mess is because it is badly written; the same would happen to XPath if the same authors used that instead.
I haven't heard this myth, and I doubt Hixie has either, since it's like comparing apples with pears. XPath expressions are used in many different places, so in and of themselves they are not a replacement for scripting. Having said that, it is true that script is very hard to maintain.
But the most bizarre of Hixie's arguments is the statement that the script we see on the web is a mess "because it is badly written". I thought for a moment that Hixie might have finally understood why we need XForms, but that glimmer of hope passed, and Hixie settled comfortably back into his two-tier world of those that can work miracles with JavaScript and the rest of us (if you have the money and playtime that Google has, then sure you can build a passable email client and a map site with JavaScript ... But then given long enough I could dig a canyon with a teaspoon).
HTML mixes presentation and content -- XForms doesn't
HTML mixes presentation and content -- XForms doesn't
False. HTML doesn't mix presentation and content-- authors do. XForms doesn't prevent the two from being mixed, in fact one of the big things people are pushing these days is SVG+XForms, which is the ultimate mix of presentation and content.
There are quite a few things going on here, so let's prise them apart. The first is that 'authors' mix up presentation and content. Once again I thought I saw the lights going on, and once again the spark died. As before we have Hixie's two-tier world of those who follow 'best practice' and those who don't -- let's blame the author.
But he fails to ask why it is that authors are forced to mix presentation and content. It's not because they are not very good programmers, but the fact is that if you use JSP, ASP, ColdFusion, or any of the enormous number of server-side tools available to build your web-sites, you will have to mix up the UI with your data. For example, you will usually have to populate your list-boxes with data from your database by sticking some angle brackets and percentage symbols right into the heart of your code.
XForms takes a completely different approach -- you can load as many 'buckets' of XML into your form as you like, and you can then populate controls from that data. The UI really is separate from the data source. And you can go further; even the parts of a form that are normally regarded as static, such as hints, captions, help text, and so on, can be provided by some data server, rather than being poked directly into the form, on the server.
The second issue is that SVG+XForms is being pushed, and that this also mixes content and presentation. Whilst Hixie is right to warn of the dangers of mixing XForms and SVG, he missed the point of my demonstration. I was showing the Mozilla calculator running with SVG buttons -- but there was no SVG in the mark-up of the form. All the SVG was in separate XBL files, making it extremely easy to keep the specifics of the UI well away from the data. If the form was rendered on a system that did not have SVG installed, then the user would just see normal buttons. (I discussed skinning the calculator in a previous blog -- "On Calculators, Mozilla, SVG and XBL".
XForms is better than HTML because it is media-independent
XForms is better than HTML because it is media-independent
False. Both HTML and XForms are as media-independent as each other. If XForms is better it has nothing to do with one or the other being media-independent.
I don't really understand this.
HTML mainly specifies how the control should look, while XForms specifies what the control should do
HTML mainly specifies how the control should look, while XForms specifies what the control should do
False. HTML doesn't specify how the controls should look at all.
I think Hixie is being a little disingenuous if he implies that the HTML mark-up:
<input type="radio" ... />
<input type="checkbox" ... />
doesn't say something about how a control should 'look'. Of course it doesn't say whether it should be green or blue, but it does imply a certain way of interacting with the data -- check boxes and radio buttons -- whilst XForms is not so prescriptive.
HTML has limitations, so it had to be replaced with XForms
HTML has limitations, so it had to be replaced with XForms
False. It's easier to fix HTML than to replace it with an entirely new language.
Hixie needs to make his mind up ... Is the solution to fix HTML or to get programmers to write better script? The problem is either with the language or with the authors -- and if it is with the language then XForms is a pretty credible attempt to fix it (which is where XForms came from in the first place).
HTML requires authors to use hacks; XForms doesn't because is cleanly designed
HTML requires authors to use hacks; XForms doesn't because is cleanly designed
False. HTML doesn't require authors to use hacks, browser bugs do. And there's no reason to believe that XForms UAs will be any less buggy than HTML UAs, if it's the same programmers writing both UAs.
This is another odd one, but I guess we have to dive in. The hacks that authors use are not to get around browser bugs -- if only that were the case. The reason authors are forced to carry out hacks is because they are having to do things that HTML and JavaScript were never designed to do. Every day we see sites having to validate data and create clever pop-up solutions for help text and calendar widgets. But whilst the HTML programmer is messing around with mouseover events and scripting, the XForms author writes the following (declarative) mark-up:
<input ref="sn">
<label>Surname:</label>
<hint>Please enter your surname</hint>
</input>
Note that whilst the JavaScript hack has to rely on platform-specific features such as the mouse, our XForms mark-up does not rely on anything like that, which means that the same form functions just as easily on a voice system, as Mikko's demonstration so effectively illustrated.
That calculator again ...
To demonstrate some of these points, I took the XForms Calculator example, which was used as an example of some of XForms' power at the W3C Plenary last week, and made an HTML version.
I did use the Mozilla calculator in my demo, but it certainly wasn't for the purpose of demonstrating the power of XForms! Adding up a few numbers and stuff doesn't take a lot, and in fact as Hixie showed you can even do a simple calculator in JavaScript. My goal in using that particular sample was to take a form that had been authored by another XForms team, and show that it could be 'skinned' very easily with nice looking aqua buttons, an LED display, and a brushed metal background, without changing the 'logic' of their application.
(To see "XForms' power" we have far more advanced demonstrations, such as searching Amazon and Google, reading RSS feeds, accessing weather web services, and so on.)
Note that I didn't fix any of the bugs in the sample there are a number of ways in which this demo is broken. I just converted the existing XHTML1+XForms+XForms Actions+XPath to the exact equivalent HTML4+JavaScript+DOM to see how it would compare.
Another example of Hixie's circular logic -- a language is devised that allows us to do things more easily, and he's surprised to discover that you can still do things the older, harder way! Anyway, what would be far more revealing would be for Hixie to take a much more substantial example, like the formsPlayer RSS Reader and convert that to HTML and JavaScript. I don't doubt that it's possible -- at least with a team of guys from Google with a month or two to spare, it probably would be -- but I can guarantee that we took less time than any scripter would (and less time than the C++ or Java equivalent, too).
What's more, the RSS Reader code is far more re-usable than any scripting equivalent would be; you could take our mark-up and completely change the user interface to suit your needs, something that would be pretty much impossible with the script version.









11 Comments:
Hey Mark!
Just wanted to clarify a few things. First of all, my post wasn't a list of problems with XForms or a list of reasons why I think XForms is not really a language suitable for the Web. It was just supposed to correct some misconceptions, without trying to take a position in either direction.
A few corrections to your post (I've ignored the various ad hominem attacks and non-sequiturs):
You say: "It is almost impossible to know which part of the script in a page is responsible for hints and captions, which therefore makes it difficult for voice systems to know what to read to a blind user, and when."
This is not a scripting problem, it's an API problem. The APIs can definitely be improved. WF2 has examples of how to improve the APIs for this exact case, in fact, giving scripts control over the hint-giving part of validation in an accessibility-friendly way.
You assert that HTML requires mixing of presentation and content because development tools suck. That is completely untrue. Maybe you meant that development tools force the mixing of content and logic. That I don't disagree with (and IMHO it's not a big deal -- that's all server side, where it doesn't affect the user).
There is nothing in HTML that forces the authors to mix presentation and content, and nothing in XForms that encourages authors to do differently. (The calculator example is a good example of XForms being used in a way that mixes presentation and content.)
I didn't miss the point of your demonstration. I didn't mention your demonstration, in fact. Your demo was very cool, and in fact skinning is just as possible with HTML as it is with XForms. Your skin with the LED display, for example, could be applied to the HTML calculator just as easily as the XForms one. XBL was originally designed for skinning XUL widgets -- it can be used for skinning HTML ones as well as XForms ones.
input type="checkbox" says nothing -- nothing -- about how the control should look. It could be a visual check mark, it could be an audio prompt, it could make the text next to it a different colour based on its state, anything. The only difference between input type="radio" and select (or input type="checkbox" and select multiple="multiple") is that the inputs can be placed along with the content, so as to make rich
(tiered) multiple choices (e.g. putting a radio button in a fieldset legend), whereas selects group the choices together in one place. They are semantically the same.
You ask if "the solution [is] to fix HTML or to get programmers to write better script" (and markup) -- IMHO, the answer is a bit of both.
Certainly many authors would benefit from writing cleaner markup, writing cleaner scripts, and so on. For instance, most authors browser-sniff when it isn't necessary, and many authors abuse the DIV element. But equally, there are obviously things about HTML that are lacking. There has long needed to be a way to say "this field is required".
JavaScript doesn't have to rely on platform-specific features such as the mouse, any more than XForms does. Events like "click" have long been defined in media-neutral ways, even before the DOM working group decided to "fix" the problem by giving events like "DOMActivate". JavaScript-based solutions, when written well, will work with all media, just like XForms solutions that are written well.
Equally, XForms solutions that are written badly will fail to work across media, just like badly-written HTML or JavaScript-based solutions. If you think authors will never write XForms that can't work across all media, then you are either assuming XForms will never become a big success, or you are assuming that all the authors who couldn't write decent HTML will write decent XForms. I assure you the latter is not true.
Could you provide some links to canonical XForms demos that work across multiple XForms UAs and that you would consider demonstrate the power of XForms over other technologies? I'd be interested in seeing some. I have so far found it quite difficult to come across any XForms demo content.
I wasn't suprised that HTML+JS could do a calculator the same as XForms, and I don't think I said I was surprised anywhere. I don't know why you suggest that I was.
You claim that with HTML+JS it is impossible to skin is, of course, ridiculous. The CSS Zen Garden is ample demonstration, but if you need more, just consider Firefox -- it is an XML+JS application (basically the same as HTML+JS), and it is completely skinned using CSS. Many dozens of radically different skins exist.
I personally like XForms. However, I think it is a lost cause on the popular Web for three reasons:
1. It's not backwards compatible with existing Web content and existing Web browsers,
2. It uses too many levels of abstraction to be understood by most authors.
3. It requires the use of many namespace prefixes.
None of these problems really have anything to do with XForms features per se. It is IMHO possible to bring many of XForms features (especially the declarative constraints ideas) to authors without introducing the other problems. For instance, by just extending HTML's form features instead of making a totally new language.
The Mozilla Calculator demo is a good basic example of what can be done with XForms, and really does little more than prove that Mozilla's new XFroms Extension works. Calculators have been done a thousand times over, and it's not that difficult to emulate it's functionality with a HTML+JS implementation.
The real trick, is to try to write their 1040-EZ form in JS. (or any other real-world application) When you start using more of the features of XForms you start to see how big of a headache you would have trying to do the exact same thing the traditional way.
The namespace issue is rather annoying. We can only hope that XHTML 2.0 and the next next-generation browsers will help to aleviate that.
I really don't think the namespace prefixes are an issue. Namespaces irritate & confuse the hell out of me, and I've wasted a lot of time chasing down namespace related issues (both mine and others).
But having spent the last few months writing XForms, namespaces haven't caused any sweat : generally it only involves using the http://www.w3.org/2002/xforms namespace, and occasionally http://www.w3.org/2001/xml-events, and it's always pretty obvious where both should apply.
YMMV however.
I suspect that better editing tools for XForms, such as those that Open Office 2.0 looks to be supporting, may make the key difference in whether or not XForms takes off. XForms ARE more complicated, especially for web developers, but just as a professional web developer will likely end up using an IDE (or less likely a WYSIWYG editor) to bang out web pages in real-world situations, XForms authors are far more likely to end up using tools to implement XForms capabilities.
Personally, I like the prospect of not having to spend a large amount of time trying to integrate and debug ASP.NET components, Struts, or other server-side solutions to the forms mess, and not having to worry about having Frontpage extensions enabled to make my forms work. Web Forms 2.0 strikes me as a major kluge - institutionalizing bad components with legacy Javascript to give me maybe a third of the power and capabilities that XForms offers effectively for free. If the popular interest I'm seeing on my own site (http://www.understandingxml.co) for XForms is any indication, people are hungry for XForms right now.
I suspect that better editing tools for XForms, such as those that Open Office 2.0 looks to be supporting, may make the key difference in whether or not XForms takes off. XForms ARE more complicated, especially for web developers, but just as a professional web developer will likely end up using an IDE (or less likely a WYSIWYG editor) to bang out web pages in real-world situations, XForms authors are far more likely to end up using tools to implement XForms capabilities.
Personally, I like the prospect of not having to spend a large amount of time trying to integrate and debug ASP.NET components, Struts, or other server-side solutions to the forms mess, and not having to worry about having Frontpage extensions enabled to make my forms work. Web Forms 2.0 strikes me as a major kluge - institutionalizing bad components with legacy Javascript to give me maybe a third of the power and capabilities that XForms offers effectively for free. If the popular interest I'm seeing on my own site (http://www.understandingxml.co) for XForms is any indication, people are hungry for XForms right now.
Ian,
If everything would stay backwards-compatible, there could be no further development.
Consider XHTML 2.0 — imo, it is a great thing as everything can be a link and be loaded from an external source — I think it would be possible to display it correctly using today's Mozilla, but not with IE or Opera.
What is so bad about Namespace-Prefixes? Namespaces is a nice thing, you don't have to reinvent everything (I personally combine a minimal self-made structure with Dublin-Core, XHTML1.1, XHTML2.0 (for the section and h, so I can create a TOC more easily) and XInclude for my CMS-Backend — for the visitor, everything is converted to normal XHTML1.1 via XSLT.)
But it is true, XForms is extremely complex, if you just want do create a little text-only form, you're definitifly faster using HTML. — Well, we'll have enough time to learn it until IE will support it or formsPlayer is as popular as Flash Player…
Hi, I was searching blogs, and came onto yours fantastic blog.
I have a niche site. It pretty much covers how make money with niche marketing.
Keep it up. I'll check back later im sure.
You have a great blog here.
I have a based business home own start site. It's about based business home own start related stuff.
Feel free to visit and let me know what you think :-)
Interesting blog. I have a best xml editor blog.
Hi i am totally blown away with the blogs people have created its so much fun to read alot of good info and you have also one of the best blogs !! Have some time check my link to !!Home business opportunity
Keep up the good work! I look forward to reading more information on your blog
Are you interested in business home make money online? If so, I have a business home make money online site.
Feel free to drop by and tell me what you think.
Post a Comment
Links to this post:
Create a Link
<< Home