Attaches properties and constraints to a nodeset in the model.
<xforms:bind id="name" nodeset="nodeset" property1 ... propertyn/>
Parameter | Type | Description |
---|---|---|
name | string | Optional. An arbitrary name that you assign to the bind. All names assigned to id attributes must be globally unique within the form. |
nodeset | XPath | An XPath expression that specifies which node or nodes in the data model are affected. This links the properties to one or more elements in a data instance. |
property | expression | The property to apply to the indicated nodeset. Property attributes are expressed as follows: property_name = setting |
The following list describes the properties you can set for a nodeset:
For example, if you had a purchase order form, you might use the following expression to set the value of the “total” node to equal the value of the "subtotal" node plus the value of the “tax” node:
calculate="../subtotal + ../tax"
Do not link a data node with a calculation to a UI element that has a value set by a an XFDL compute. When the XForms UI binding transfers data to the UI element, the XFDL compute is destroyed.
This property is set by any XPath expression that results in a Boolean value. True means the constraint has been met, false means it has not.
For example, the following expression would ensure that the value for the upperPage node was always greater than or equal to the value of the lowerPage node:
nodeset="pagination/upperPage"
constraint=". >= ../lowerPage"
If a constraint is set for a data node, and a different constraint is set for a linked UI element, then the validity of the data is determined by considering both settings. If the data is invalid for either setting, the data will be considered invalid overall.
If a node is relevant (see the following) and has a failed constraint, then an XForms submission is not permitted.
This property is set by any XPath expression that results in a Boolean value. True means the node is readonly, false means the node is not.
For example, the following expression would make the associated node readonly:
readonly="true()"
This property is set by any XPath expression that results in a Boolean value. True means the node is relevant, false means the node is not.
For example, the following expression would make the node relevant if another node named “paymentType” had a value of “credit”:
nodeset="creditCardNumber"
relevant="../paymentType = 'credit'"
This property is set by any XPath expression that results in a Boolean value. True means the node is required, false means the node is not.
For example, the following expression would set the node to require input:
required="true()"
If a relevant (see the previous) data node is required but empty, then an XForms submission in not permitted.
For example, the following expression sets the node to a date type:
type="xsd:date"
If the data type set for the node conflicts with the data type set for a linked UI element, then the validity of the data is determined by considering both settings. If the data is invalid for either setting, the data will be considered invalid overall.
For example, if you set a data node to be type int and you set a linked XFDL field to be type string, then typing in "abc" (a valid XFDL string) would still result in an error, since it does not match the int type.
If a relevant (see the previous) data node's content does not match its type, then an XForms submission is not permitted.
xforms:model
This example shows a small XForms data model that contains the name, age, and birth date of a person. The model includes a bind that sets the datatype of <age> to xsd:integer and a bind that sets the datatype of <birthdate> to xsd:date.
<?xml version="1.0"?>
<XFDL xmlns="http://www.ibm.com/xmlns/prod/XFDL/8.0"
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/8.0"
xmlns:xforms="http://www.w3.org/2002/xforms">
<globalpage sid="global">
<global sid="global">
<xformsmodels xmlns="">
<xforms:model>
<xforms:instance>
<person>
<name></name>
<age></age>
<birthdate></birthdate>
</person>
</xforms:instance>
<xforms:bind nodeset="age" type="xsd:integer"/>
<xforms:bind nodeset="birthdate" type="xsd:date"/>
<xforms:submission id="submitTest" method="post"
resource="http://www.example.com/cgi-bin/people"
includenamespaceprefixes=""/>
</xforms:model>
</xformsmodels>
</global>
</globalpage>
<xforms:bind nodeset="instance('Generated')/page1/field1"
calculate="concat('instance('Generated')/page1/field1','')"/>