Single Node Binding Attributes

Release 2.0 - ...

The following attributes can be used to define a binding between an XForms element such as a form control or an action and an instance data node defined by an XPath expression.

Most XForms elements require a Single Node Binding, in which case one of ref or bind is required.

ref

Binding expression interpreted as XPath. This attribute has no meaning when a bind attribute is present.

In the example below, the instance data node a:Zip is bound to the input element.

Example

XML CopyCode image Copy Code
<xforms:input ref="a:Zip">
    <xforms:label>Postal Code:</xforms:label>
</xforms:input>

model

Author-optional XForms model selector. Specifies the ID of an XForms model to be associated with this binding element. This attribute has no meaning when a bind attribute is present.

In the example below, the xforms:input element is bound to the number (default) instance data node within the model with ID pay.

Example

XML CopyCode image Copy Code
<xforms:input ref="my:number" model="pay">
    <xforms:label>Credit Card Number:</xforms:label>
</xforms:input>

bind

Author optional reference to a bind element.

In the example below, the input element is bound to the node which is selected by the nodeset attribute of the bind element with ID firstname

Example

XML CopyCode image Copy Code
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
 xmlns:xforms="http://www.w3.org/2002/xforms"
 xmlns:my="http://example.com">
 <xhtml:head>
     <xforms:model>
         <xforms:instance xmlns="">
       <my:user>
           <my:first>Seth</my:first>
     <my:last>Peters</my:last>
     <my:email>speters@example.com</my:email>
       </my:user>
   </xforms:instance>
   <xforms:bind id="firstname" nodeset="my:first"/>
   <xforms:bind id="lastname" nodeset="my:last"/>
     </xforms:model>
 </xhtml:head>
 <xhtml:body>
     <xforms:input bind="firstname">
         <xforms:label>First Name : </xforms:label>
     </xforms:input>
 </xhtml:body>
</xhtml:html>

 

Specification

Link to the XForms specification: Single Node Binding Attributes