THIS POST IS SUPERSEDED BY A NEW SERIES OF ARTICLES ON XML TECHNOLOGIES AND XFORMS... READ MORE IN PART 5 OF THE XFORMS TUTORIAL...
As long as I can keep up with it, I'm trying to track people who are linking to this weblog and saying thanks! Molly E. Holzschlag added the tutorial to her list of links. Her bio says "Molly E. Holzschlag has authored over 30 books related to Web design and development. She's been coined "one of the greatest digerati" and deemed one of the Top 25 Most Influential Women on the Web." Wow! And thanks for mentioning me.
XForms can be overwhelming. Let's start hello-world-style. First of all, you need an XForms engine. I prefer the Mozilla implementation, but it isn't finished yet. I fail to get some essential features to work. These should be fixed if I would download the latest source code and compile it myself. But in the latest beta, it doesn't work yet. Nevertheless, I'll start with Mozilla, and when I need it, I'll introduce an alternative implentation. I think it's interesting anyway to investigate to which extent XForms are portable and compatible for different viewers.
Getting XForms for Mozilla
XForms for Mozilla is an XPI plugin and is not preinstalled together with the browser. In the current plans, this will not change for the initial releases. The XForms beta does not work with current releases of Firefox (up to 1.0.3). You need to download the 1.0+ version separately before you can install the plugin. This is 20050523, for the most recent information and downloads, visit the Mozilla XForms project page.
It took some time before it was decided that XForms was implemented on the Mozilla platform. The reason for this resistance is interesting enough to mention here. There is a relation between whether you like XForms or not and whether you are an application developer or a pure web developer. Web developers like to keep things easy, user friendly and error forgiving. They prefer HTML over XHTML and are more interested in its layout capabilities than its semantic capabilities. Application developers prefer more sophisticated modeling tools that fail fast on errors and force developers into adhering to strict standards. Web developers think this makes it all more complicated than necessary.
XForms is an extensive modeling tool with many features more interesting to application developers than to web site designers. The decision to implement XForms on the Mozilla platform was pushed (not to say "forced") by several large companies (Novell, IBM). While some are arguing that Firefox should be a web browser and nothing but a web browser, these large companies have enough interest in Mozilla as an application platform to invest in its development.
I consider myself an application developer who develops web applications by coincidence. This explains a little my interest in XForms. How complicated XForms are (or not), is something this tutorial should point out.
Enough with the background information.
A very basic XForm
<?xml version="1.0" encoding="iso-8859-1"?>
<html:html xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events">
- <html:head>
- <xf:model>
- <xf:instance id="resume">
- <resume xmlns="">
- <firstname>Adriaan</firstname>
<lastname>de J.</lastname>
<html:body>
- <html:p>
- Resume for
<xf:output ref="instance('resume')/firstname" />
<xf:output ref="instance('resume')/lastname" />
<html:p>
- First name: <xf:input ref="instance('resume')/firstname" />
<html:br />
Last name: <xf:input ref="instance('resume')/lastname" />
If you have the right version of Mozilla and the plugin, you can view the example here.
This example is extremely basic. It does almost nothing. The only interesting thing you see here, is that when you change a value in one of the text boxes and tab to the next field, the information in the output fields automatically changes. Probably you think this is not earth shocking, but please note there is NO scripting in this example, and there aren't even XML triggers or events defined. This works out of the box; a standard declarative feature.
I'll leave it at this for a hello world.
What else do you notice?
I see an event namespace being declared but not being used. I could have deleted it for this example. It will be used later on in the tutorial.
I see separate namespaces for XHTML and XForms. They mix with each other. This indicates that XForms is very modular. It is possible to build an XForm without XHTML. For instance, you could also mix it with SVG. With a little fantasy, you could design eye-candy graphical interfaces mixing with data source documents in a very dynamic interactive way.
I see instance data mixed in the document. In practice, most likely this mixing is evil. In the next example you'll see the instance data replaced by a reference to an external file.
That's pretty much it for this simplistic example. From here we can introduce features to build the full curriculum vitae document. Stay tuned!
THIS POST IS SUPERSEDED BY A NEW SERIES OF ARTICLES ON XML TECHNOLOGIES AND XFORMS... READ MORE IN PART 5 OF THE XFORMS TUTORIAL...