Re: Question about form design with optional elements

Hello

CJ Another approach is to start with a maximal base instance,
CJ 
CJ   <xf:instance id="maximal-base">
CJ     <X>
CJ       <a/>
CJ       <b/>
CJ       <c/>
CJ     </X>
CJ   </xf:instance>
CJ 
CJ and then remove any of the optional elements that are "empty" when the 
CJ instance is submitted.  This approach requires expanding the starting 
CJ state of the instance data to its maximal form before editing, and then 
CJ pruning it back again after editing.  Our experiments have performed 
CJ both expanding and pruning on the server side, although it may be 
CJ possible to do these operations using XForms itself.  For example, 
CJ pruning could be implemented using some creative "relevance" MIPs.  

This is what relevance is for. It needn't be very creative. Something 
like:

<xf:bind nodeset="instance('maximal-base')/*" relevant=".!=''"/>

would do it. You might need to use CSS to ensure that elements are still 
visible and editable while they are empty. But relevance will remove the 
empties before the instance is submitted.

Swithun.

Received on Thursday, 17 July 2008 08:19:45 UTC