XForms/Incremental Many to One
Motivation
[edit | edit source]Sometimes a single input field will be used to create a new output. Not only does the input field need to be updated, but other fields that depend on this input also need to change.
Here is an example program that has three input fields. As an example, it uses a data dictionary entry (called a Data Element). The name of the Data Element is a concatenation of three fields: the Object Class Name, the Property Name and the Representation Term. The first two are text fields and the third is a value that is picked from a list.
This form creates a single output based on the values of the input fields. This shows that the model can take many different inputs and create a single output.
Link to working XForms Application
[edit | edit source]Sample Code
[edit | edit source]<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms">
<head>
<title>Many to one</title>
<xf:model>
<xf:instance xmlns="">
<DataElement>
<ObjectClassName />
<PropertyName />
<RepresentationTerm />
</DataElement>
</xf:instance>
</xf:model>
</head>
<body>
<xf:group nodeset="/DataElement">
<fieldset>
<legend>Data Element Name</legend>
<xf:label>DataElementName: </xf:label>
<xf:output value="concat(ObjectClassName, ' ', PropertyName, ' ', RepresentationTerm)"/>
<p>
<xf:input ref="ObjectClassName" incremental="true">
<xf:label>Object Name:</xf:label>
</xf:input>
</p>
<p>
<xf:input ref="PropertyName" incremental="true">
<xf:label>Property Name:</xf:label>
</xf:input>
</p>
<p>
<xf:select1 ref="RepresentationTerm" incremental="true">
<xf:label>Representation Term:</xf:label>
<xf:item>
<xf:label>Amount</xf:label>
<xf:value>Amount</xf:value>
</xf:item>
<xf:item>
<xf:label>Code</xf:label>
<xf:value>Code</xf:value>
</xf:item>
<xf:item>
<xf:label>Count</xf:label>
<xf:value>Count</xf:value>
</xf:item>
<xf:item>
<xf:label>ID</xf:label>
<xf:value>ID</xf:value>
</xf:item>
<xf:item>
<xf:label>Indicator</xf:label>
<xf:value>Indicator</xf:value>
</xf:item>
<xf:item>
<xf:label>Name</xf:label>
<xf:value>Name</xf:value>
</xf:item>
<xf:item>
<xf:label>Percent</xf:label>
<xf:value>Percent</xf:value>
</xf:item>
<xf:item>
<xf:label>Text</xf:label>
<xf:value>Text</xf:value>
</xf:item>
</xf:select1>
</p>
</fieldset>
</xf:group>
</body>
</html>
Discussion
[edit | edit source]How can you then take that output and put it back into the model? This will be covered later in the tutorial.