- From: Mark Birbeck <mark.birbeck@webbackplane.com>
- Date: Thu, 6 Aug 2009 15:54:15 +0200
- To: adam.flinton@nhs.net
- Cc: "www-forms@w3.org" <www-forms@w3.org>
HI Adam,
> I wonder if there is scope within any improvements to XForms to have a
> <xforms:variable/> element
>
> Much as with XSLT or similar......
It's been discussed many times over the years, and I'm sure it will happen.
> The normal use cases are wrt checking values e.g. my "check unique" check:
>
> <xforms:bind
> calculate="if(instance('OIDVals')/oids/@active = 1,true(),if
> (count(instance('OIDVals')//ov[@full = instance('main')/@full]) <=
> instance('OIDVals')//oids[1]/@exist,true(),false()))"
> id="unique_OID" nodeset="instance('uniqueOID')/@val"/>
>
> Or as stated in the previous post wrt displaying one group vs another.
If you have multiple groups, and multiple possible values (obtained
via @calculate) then you could use a clever little trick that I first
saw used by David Landwehr.
The idea is to bind multiple groups to the same node (in your case it
might be @val), but to then add an XPath filter with the expression
you want relevance to be based on:
<xf:group ref="instance('uniqueOID')">
<xf:group ref="@val[. = 1]">
...
</xf:group>
<xf:group ref="@val[. = 2]">
...
</xf:group>
<xf:group ref="@val[. = 3]">
...
</xf:group>
</xf:group>
This has the effect of creating an empty nodeset for each @ref that
contains a filter that evaluates to false. The default behaviour in
XForms, for a binding to a node that doesn't exist, is to act as if
the binding is to a non-relevant node.
In short, you should only ever get a maximum of one of these groups
being relevant at any one time, and with this approach there is no
need to use xf:bind, other than for the calculation to set the
selection criteria.
Regards,
Mark
--
Mark Birbeck, webBackplane
mark.birbeck@webBackplane.com
http://webBackplane.com/mark-birbeck
webBackplane is a trading name of Backplane Ltd. (company number
05972288, registered office: 2nd Floor, 69/85 Tabernacle Street,
London, EC2A 4RR)
Received on Thursday, 6 August 2009 13:54:59 UTC