マガジン XForms · 137 ページ中 46 ページ目
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.
このページを含むマガジンXForms
ライセンス: CC BY-SA 4.0 · 出典 en.wikibooks.org
1
0
0
0

コメント






