Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 2 min read

Support

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

xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:foobar="http://www.example.com">

Binds to Multiple Instances in Multiple Models
type="text/css">
@namespace xf url("http://www.w3.org/2002/xforms");
body {font-family: Helvetica,sans-serif}
xf|label {font-weight: bold}

id="model-1">

id="instance-1-1" xmlns="">

Hello World Model 1 Instance 1!

id="bind-1-1" nodeset="instance('instance-1-1')/Message" />

id="instance-1-2" xmlns="">

Hello World Model 1 Instance 2!

id="bind-1-2" nodeset="instance('instance-1-2')/Message" />

id="model-2">

id="instance-2-1" xmlns="">

Hello World Model 2 Instance 1!

id="bind-2-1" nodeset="instance('instance-2-1')/Message" />

id="instance-2-2" xmlns="">

Hello World Model 2 Instance 2!

id="bind-2-2" nodeset="instance('instance-2-2')/Message" />

Model 1
model="model-1">
ref="instance('instance-1-1')/Message">
ref="instance('instance-1-1')/Message":

bind="bind-1-1">
bind="bind-1-1":

ref="instance('instance-1-2')/Message">
ref="instance('instance-1-2')/Message":

bind="bind-1-2">
bind="bind-1-2":

Model 2
model="model-2">
ref="instance('instance-2-1')/Message">
ref="instance('instance-2-1')/Message":

bind="bind-2-1">
bind="bind-2-1":

ref="instance('instance-2-2')/Message">
ref="instance('instance-2-2')/Message":

bind="bind-2-2">
bind="bind-2-2":

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.

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
Here is a simple example of how to get a list of repeating data elements out to your screen. This is done using the repeat tag and the nodeset attribute. You use the nodeset to specify where you want to begin your listing in the model. In this case we are just using a model embedded into the page.
CC BY-SA 4.0
nodeset="//my-node"> ref=".[element1='true']"> ref="element2"/> The syntax **.[a='b']** says that from the current node if the element **a** equals the value **b** then output the elements within the group. ### Conditional Formatting of Items This same strategy can be used to enclose output in diffe
CC BY-SA 4.0
XForms, Formatting Numbers
CC BY-SA 4.0
Your input instance is like the following: id="link-items" xmlns=""> 1 One 2 Two 3 Three ## Discussion With XForms it is not possible to create dynamic links inside a repeat using a combination of **output**, **value** and **concat**. This would also impact the ability to notify the user that is nav
CC BY-SA 4.0
XForms, Switch and Case
CC BY-SA 4.0
ref="/var/first" > Should I show the second question? /> select="yes"> Yes Please! 1 No Thank You 0 /> ref="/var/second"> Second value: ## Using Multiple Predicates in Binds Sometimes you have a sequence of many items and the display of one item depends on the values of other items. Predicates are a