Wednesday, April 18, 2012

XForms 2.0: goodbye nodeset

XForms 1.1 makes a distinction between two commonly-used attributes: ref and nodeset. Both are binding attributes, and they hold an XPath expression pointing to zero, one or more XML element or attribute nodes:

  • ref points to a single node ("single-node binding"). Its most frequent use is to bind a control such as xforms:input to XML data.
  • nodeset points to any number of nodes ("node-set binding"). This is used for example by xforms:repeat and xforms:itemset, which iterate over multiple nodes.
While working on the upcoming XForms 2.0 specification, which fully supports XPath 2.0, the XForms Working Group noticed a problem: node-set is terminology from XPath 1.0, and XPath 2.0 instead uses the more general notion of sequence. So keeping an attribute named nodeset in XForms 2.0 would be quirky!

The good news is that the solution is very simple, because it turns out that having two separate attributes is not necessary in the first place. So the Working Group has decided that XForms 2.0 will use ref everywhere and deprecate nodeset, keeping it around for backward compatibility only.

This has the additional benefits of simplifying the XForms syntax and removing a possible source of confusion for form author (e.g. which attribute should you use on xforms:bind?).

So get used to write:
<xforms:repeat  ref="foo">
<xforms:bind    ref="bar">
<xforms:itemset ref="baz">
<xforms:delete  ref="qux">
Another good news: Orbeon Form already supports "ref everywhere" since version 3.9, so feel free to drop good old nodeset!

No comments:

Post a Comment