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

RE: Question re bind constraint

From: John Boyer <JBoyer@PureEdge.com>
Date: Tue, 14 Dec 2004 09:34:39 -0800
Message-ID: <7874BFCCD289A645B5CE3935769F0B52D883D6@tigger.pureedge.com>
To: "Chris Picton" <xforms-list@tangent.co.za>, <www-forms@w3.org>

Hi Chris,

I think you will be able to do this more easily in XForms 1.1 due to the addition of the current() function.

Say you have 
<numbers>
   <number>1</number>
   <number>2</number>
   <number>3</number>
   ...
</numbers>

in an instance with id="nums"

And you have a default instance with

<data>
   <result/>
</data>

Now make an <input ref="result">...

Finally, make a constraint

<bind nodeset="result" constraint="not(instance('nums')/number[text()=current()])"/>

There are numerous other use cases that caused us to add current() to be able to achieve this type of table lookup; yours is another good one!  I think at least some of the xforms 1.0 implementations offer current() as an extension function.  So you can use the above as long as your model lists current in the functions attribute, e.g.

<model functions="current">
  the instances and bind above
</model>

If your chosen implementation doesn't support this extension, it will report an error when it reads the functions attribute.

Cheers,
John Boyer, Ph.D.
Senior Product Architect and Research Scientist
PureEdge Solutions Inc.



-----Original Message-----
From: Chris Picton [mailto:xforms-list@tangent.co.za]
Sent: Tuesday, December 14, 2004 1:51 AM
To: 'www-forms@w3.org '
Subject: Question re bind constraint



Hi all

I have a form which has two instances.

The first instance is the actual data which is being edited, and the
second is a list of unique numbers.

One of the fields in the form requires a number to be entered, but it
must be different to any of the numbers in the second instance.

Is there any way to enforce this via xforms constraints?

Regards
Chris
-- 
Chris Picton <xforms-list@tangent.co.za>
Tangent Systems
Received on Tuesday, 14 December 2004 17:37:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:21:59 GMT