XForms/Binds to many instances

Motivation
You often want to be able to bind to different instances in different models. This sample program shows you how to do this. Creating separated models is critical to allow clean submissions. You should always structure so that your submission data is in a single model. But this creates problems when referencing data elements without specifying what model the instance is part of.

Note in the example below the group element encloses the output for each model.

Sample Program
              Model 1   <xf:label>ref="instance('instance-1-1')/Message":</xf:label> </xf:output> <xf:output bind="bind-1-1"> <xf:label>bind="bind-1-1":</xf:label> </xf:output> <xf:output ref="instance('instance-1-2')/Message"> <xf:label>ref="instance('instance-1-2')/Message":</xf:label> </xf:output> <xf:output bind="bind-1-2"> <xf:label>bind="bind-1-2":</xf:label> </xf:output> </xf:group> Model 2 <xf:group model="model-2"> <xf:output ref="instance('instance-2-1')/Message"> <xf:label>ref="instance('instance-2-1')/Message":</xf:label> </xf:output> <xf:output bind="bind-2-1"> <xf:label>bind="bind-2-1":</xf:label> </xf:output> <xf:output ref="instance('instance-2-2')/Message"> <xf:label>ref="instance('instance-2-2')/Message":</xf:label> </xf:output> <xf:output bind="bind-2-2"> <xf:label>bind="bind-2-2":</xf:label> </xf:output> </xf:group>

Discussion
Note that you can not bind across models. This implies that complex calculations that need to access instance data in multiple models need to copy them into a single model before calculations are done.