W3C home > Mailing lists > Public > www-forms@w3.org > July 2006

Re: Can you nest if statements within Xforms constraints?

From: Steven Pemberton <steven.pemberton@cwi.nl>
Date: Mon, 31 Jul 2006 15:50:26 +0200
To: "Flinton Adam" <Adam.Flinton@cfh.nhs.uk>, www-forms@w3.org
Message-ID: <op.tdj3eco1smjzpq@acer3010.lan>

On Mon, 31 Jul 2006 14:08:52 +0200, Flinton Adam <Adam.Flinton@cfh.nhs.uk>  
wrote:

> So many question is....can an if statement in a constraint be nested
> within another if statement?

Yes it can. By the way, it is a function, not a statement.

Some quick points:

1. If you use calculate='...', you don't need to use readonly='true()',  
because that is the default in that case.

2. constraint="if(../OID_key !=  
0,if(count(instance('All_comp_OID')//comp_OID[text() =  
instance('main')/comp_OID/text()]) = 0,true(),false()),true())" />

       if(a, (if b, true, false), true)

can be written:

	if(not(a) or b)

that is:

	constraint="../OID_key = 0 or  
count(instance('All_comp_OID')//comp_OID[text() =  
instance('main')/comp_OID/text()]) = 0"

or shortcutting the evaluation::

		constraint="if(../OID_key = 0, true(),  
count(instance('All_comp_OID')//comp_OID[text() =  
instance('main')/comp_OID/text()]) = 0)"

so you don't need the nesting.

Sorry this doesn't solve your real problem though.

Steven Pemberton
Received on Monday, 31 July 2006 13:53:03 GMT

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