Re: Can you nest if statements within Xforms constraints?

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 UTC