W3C home > Mailing lists > Public > public-forms@w3.org > March 2008

Bind ids vs. bind names, and further use of the name attribute

From: Erik Bruchez <ebruchez@orbeon.com>
Date: Wed, 26 Mar 2008 17:16:17 -0700
Message-Id: <A0F9B6FF-4839-4B90-8E2D-4B97E07BF4C7@orbeon.com>
To: public-xforms@w3.org


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 name="repeat2">
       <xf:input name="first-name"/>

   The corresponding data structure would look like this:


   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 nodeset="repeat2">
       <xf:bind id="first-name" nodeset="first-name"/>

   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 nodeset="repeat2">
       <xf:bind name="first-name" nodeset="first-name"/>

* 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.


Orbeon Forms - Web Forms for the Enterprise Done the Right Way
Received on Thursday, 27 March 2008 00:17:00 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:13:56 UTC