- From: Erik Bruchez <ebruchez@orbeon.com>
- Date: Wed, 26 Mar 2008 17:16:17 -0700
- To: public-xforms@w3.org
All,
I would like to suggest that we introduce a @name attribute on
xforms:bind to supplement the use of @id. There are several reasons
for this:
* In our current proposal for simplified syntax, we plan to use the
@name attribute on controls. Names don't have to be unique, yet the
corresponding xforms:bind/@id would have to be unique for the whole
document. This is an issue.
Consider the following example, which looks reasonable to me:
<xf:repeat name="repeat1">
<xf:input name="first-name"/>
</xf:repeat>
<xf:repeat name="repeat2">
<xf:input name="first-name"/>
</xf:repeat>
The corresponding data structure would look like this:
<form>
<repeat1>
<first-name>Joe</first-name>
<first-name>Anna</first-name>
</repeat1>
<repeat2>
<first-name>Mary</first-name>
<first-name>Bob</first-name>
<first-name>etc.</first-name>
</repeat>
</form>
If we translate this to canonical XForms using xforms:bind/@id, this
will obviously fail because there a duplicate id will be produced:
<xf:bind nodeset="repeat1">
<xf:bind id="first-name" nodeset="first-name"/>
</xf:bind>
<xf:bind nodeset="repeat2">
<xf:bind id="first-name" nodeset="first-name"/>
</xf:bind>
Using @name instead, you don't have a duplicate id, yet the name can
be resolved to the proper bind depending on whether you are within
the context of the first repeat or the second repeat:
<xf:bind nodeset="repeat1">
<xf:bind name="first-name" nodeset="first-name"/>
</xf:bind>
<xf:bind nodeset="repeat2">
<xf:bind name="first-name" nodeset="first-name"/>
</xf:bind>
* The use of @id to name things is in general quite limiting. It makes
sense to uniquely identify an element in a document, but it fails
wherever encapsulation and modularity are needed.
As a concrete example, there doesn't seem to be a particularly good
reason why, in two separate models, you couldn't have instances
named the same way, since anyway we have the @model attribute
available to specify where to search for the instance. This is all
the more true if you modularize a form using XInclude, for example.
In general I think that it is better, for referring to objets such
as instances, binds, functions, variables, etc. to use a @name
instead of an @id attribute.
* One idea was that binds would automatically declare variables. If we
use the @name attribute, we can better control which bind do declare
variables and which don't, since we could say that only those bind
with a @name attribute (as opposed to an @id attribute) would
effecively declare variables.
* The above also would make things more consistent with the future
introduction of proper variables, which I expect, in order to
reflect existing usage in XSLT, would be referred to by name:
<xf:variable name="foobar" .../>
It would be awkward to have variables sometimes defined by @name,
and sometimes by @id.
* This is more consistent with our term of "named binds" ;-)
Thoughts welcome.
-Erik
--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/
Received on Thursday, 27 March 2008 00:17:00 UTC