Anne van Kesteren

Repeating form controls

There are currently two repeating models specified and both are quite theoretical as far as the web is concerned. Although there are some implementations of XForms they require a plugin. And the “extension” (apparently different from a plugin) I would like to use doesn’t support the repeat module yet. For the record, it will remain an extension for now, presentations that state otherwise are wrong.

I guess I need some disclaimer. Some parts of the specifications are a bit unclear to me and the Web Forms 2 specification might change. Although it is considered stable at the moment, the repetition model really might change as the specification is not yet a recommendation and there is a special note about it at the top of the draft. I mailed www-forms about one issue and the WHATWG about two issues that are unclear to me.

You can find the repeating form controls sections here (Web Forms 2) and here (XForms 1). (The lack of good link text is made up by adding a proper TITLE attribute.) The difference between the specifications is that XForms defines two repeating models and Web Forms 2 defines a single repeating model covering all cases. I wonder why XForms needs two, but it is too late to change that. Because now XForms is a recommendation, we can not change it anymore for the better since that would break backwards compatibility. XForms broke backwards compatibility as well, but you should not do that too often I guess.

In Web Forms 2 you create a repeating form control using the REPEAT attribute. In HTML context that’s that. In an XML document it depends. If you are declaring the REPEAT attribute on an element in the XHTML namespace you can leave it in no namespace. If you are declaring it on an element either not in a namespace or another namespace that is not equal to the XHTML namespace the REPEAT attribute needs to be in the XHTML namespace. For example:

<foo xmlns=",2005-03-23:foo-ns" xmlns:xhtml="">
 <foobar xhtml:repeat="template">

It is a bit unclear how the repeating attributes from XForms work, but I assume (reading the non-normative examples) the same as in Web Forms 2. XForms also has a REPEAT element however. I’m not sure why that is needed as pointed out above, but perhaps it can be of use to some people. A problem it might cause is that implementations will spend less effort on the more useful repeating scheme as that is more difficult to implement. (See the Mozilla bug for repeating attributes in XForms for an example.)

I think the repeating schemes are very useful for simplyfying complex tasks, although you need to have some backwards compatible method if you want to deploy it today. Some server-side method that addresses that concern can be found here (implemented in Perl).


  1. The long line of code in this post runs through the links on the side. They also jump when hovering over them in Opera. (7.54u2/WinXP.)

    Posted by Chris Hester at

  2. How does forcing me to hover over a link to get a description make up for bad link text?

    Posted by Joseph Huang at

  3. Chris, I assume your problem has been solved by the addition of new articles?

    Josheph, I do not think it does. However, that might be bad user interface design by the browser as well. Depends on how you think of it.

    Posted by Anne at

  4. It might be bad browser design, but putting link text as "here", "one issue", etc is still a bad idea. Something is backwards when you substitute link text quality for title attribute quality. You could simply make the link text "Web Forms 2: repetition" or something similar. Same goes for "one issue", it would be much better if you actually said what the issue is rather than an almost meaningless word.

    Posted by Joseph Huang at