Hub Nexus
Opdateret

ForfatterIngen forfatter endnuOvertag den

Ser du noget at forbedre? Foreslå en ændring.

Støtte

I XForms · side 46 af 137

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.

I disse publikationerXForms

SprogEnglish

Licens: CC BY-SA 4.0 · Bearbejdet efter en.wikibooks.org

1

0

0

0

Spinner Logo

Kommentarer

Spinner Logo
Version: 2CC0 1.0 — public domain
The runaway star that left the Tarantula Nebula
Version: 2CC0 1.0 — public domain
The Blackwell School, where segregation had no law behind it
Version: 2CC0 1.0 — public domain
The Eagle Nebula, seen in the infrared
Version: 2CC0 1.0 — public domain
The house where the Equal Rights Amendment was written
Version: 2CC0 1.0 — public domain
The Aleutians, the forgotten front of the Second World War
Version: 2CC0 1.0 — public domain
The Cosmic Cliffs are not cliffs