W3C home > Mailing lists > Public > www-forms@w3.org > December 2004

RE: adding bindings in the model with XForms actions?

From: Mark Birbeck <mark.birbeck@x-port.net>
Date: Mon, 20 Dec 2004 15:25:09 -0000
To: <popescu@cs.helsinki.fi>
Cc: <www-forms@w3.org>
Message-ID: <007701c4e6a8$17653760$6f01a8c0@W100>

Hi Andrei,

The first thing to note is that *all* your current bind statements are

>         <bind nodeset="thumbnail[1]/@src" calculate="image[1]/@src"/>
>         <bind nodeset="thumbnail[2]/@src" calculate="image[2]/@src"/>
>         <bind nodeset="thumbnail[3]/@src" calculate="image[3]/@src"/>

The MIP attributes (calculate, readonly, relevant, etc.) are relative to the
nodeset iterated by @nodeset, so your first bind statement says:

  to the value of:

which is obviously incorrect. Since you obviously want this:

  to the value of:

then you need to do this:

  <bind nodeset="thumbnail[1]/@src"
calculate="../../../images/image[1]/@src" />

or this:

  <bind nodeset="thumbnail[1]/@src"
calculate="/photoalbum/images/image[1]/@src" />

Anyway, on to the main point of your question -- how to insert new nodes and
still maintain this calculation. XForms already supports what you want,
since <bind> operates over nodesets. All you need to do is change your
@nodeset value to:

  <bind nodeset="thumbnail/@src" ... />

and the rule will apply to all @src attributes or all thumbnail elements. If
a new one is inserted, or one deleted, then the list of nodes in the nodeset
is recreated (which is why a rebuild is triggered when you do insert or

The actual calculation to perform for each node would be something like


I don't have time to check this but I'll explain what it's doing in case you
need to tweak it:

1. Get a list of the thumbnail elements prior to the current one:


   Note that this works because @nodeset uses @calculate multiple times
   for each node in the list created by @nodeset.
2. Count the 'preceding' nodes:

     count( ... )

3. Use that value to offset into the list of image elements, and get the src

     ../../../images/image[ ... ]/@src



Mark Birbeck
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
w: http://www.formsPlayer.com/

Download our XForms processor from
Received on Monday, 20 December 2004 15:25:18 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:14 UTC