XForms appendices

Get XForms specification information and sample code here

Return to article

Appendix A: Sample code listing: Order form example in its entirety

<HTML xmlns="http://www.w3.org/1999/xhtml"  
  xmlns:xforms=http://www.w3.org/2002/01/xforms
  xmlns:ev="http://www.w3.org/2001/xml-events" 
  xmlns:xlink="http://www.w3.org/1999/xlink">
   <head>
      <title>XForms: Order Form</title>
      <link rel="stylesheet" type="text/css" href="AES.css">
<xforms:model id="data">
         <xforms:instance>
            <OrderInfo>
               <PersonalInfo>
                  <Name>
                     <First></First>
                     <Middle></Middle>
                     <Last></Last>
                  </Name>
                  <Address>
                     <Street></Street>
                     <City></City>
                     <State></State>
                     <Zip></Zip>
                  </Address>
               </PersonalInfo>
               <PriceInfo>
                  <SubTotal></SubTotal>
                  <TaxTotal></TaxTotal>
                  <TaxRate></TaxRate>
                  <Total></Total>
               </PriceInfo>
               <TaxInfo>
                  <CT>.060</CT>
                  <NY>.085</NY>
                  <NJ>.083</NJ>
               </TaxInfo>
               <ShoppingCart>
                  <ProductInfo name="itm1">
                     <Quantity>5</Quantity>
                     <Description>Wht. Chocolate Bars</Description>
                     <UnitPrice>1.45</UnitPrice>
                     <ItemTotal>7.25</ItemTotal>
                  </ProductInfo>
                  <ProductInfo name="itm2">
                     <Quantity>8</Quantity>
                     <Description>Blk. Chocolate Bars</Description>
                     <UnitPrice>1.45</UnitPrice>
                     <ItemTotal>11.40</ItemTotal>
                  </ProductInfo>
                  <ProductInfo name="itm3">
                     <Quantity>2</Quantity>
                     <Description>Car. Filled Choc</Description>
                     <UnitPrice>1.80</UnitPrice>
                     <ItemTotal>3.60</ItemTotal>
                  </ProductInfo>
               </ShoppingCart>
            </OrderInfo>
        </xforms:instance>
        <!--Data Bindings-->
        <xforms:bind ref="/OrderInfo/PriceInfo/TaxRate" 
   calculate="/OrderInfo/TaxInfo/CT"
   relevant="/OrderInfo/PersonalInfo/Address/
              State = 'CT'"/>
        <xforms:bind ref="/OrderInfo/PriceInfo/TaxRate" 
   calculate="/OrderInfo/TaxInfo/NY"
   relevant="/OrderInfo/PersonalInfo/Address/
              State = 'NY'"/>
        <xforms:bind ref="/OrderInfo/PriceInfo/TaxRate" 
   calculate="/OrderInfo/TaxInfo/NJ"
   relevant="/OrderInfo/PersonalInfo/Address/
                                  State = 'NJ'"/>
        <xforms:bind ref="/OrderInfo/PriceInfo/SubTotal"
                      type="xsd:decimal"/>
        <xforms:bind ref="/OrderInfo/PriceInfo/TaxTotal"
   calculate="/OrderInfo/PriceInfo/TaxRate * 
              / OrderInfo/PriceInfo/SubTotal"/>
        <!--Submit Info-->
  <xforms:submission id="submit1" action=http://www.example/ 
   method="post"/>

      </xforms:model>
   </head>
<body>
   <xforms:group>
    <div>
      <xforms:input class="First" id="first"
                     ref="OrderInfo/PersonalInfo/Name/First">
         <div>
            <xforms:label>First Name</xforms:label>
         </div>
         <xforms:hint>Enter First Name</xforms:hint>
      </xforms:input>
      <xforms:input class="Middle" id="middle" 
                    ref="OrderInfo/PersonalInfo/Name/Name/Middle">
         <xforms:label class="label">Middle Initial</xforms:label>
         <xforms:hint>Enter Middle Initial</xforms:hint>
      </xforms:input>
      <xforms:input class="Last" id="last" 
                    ref="OrderInfo/PersonalInfo/Name/Name/Last">
         <xforms:label class="label">Last Name</xforms:label>
         <xforms:hint>Enter Last Name</xforms:hint>
      </xforms:input>
   </div>
   <div>
      <xforms:input class="Street" id="street" 
                    ref="OrderInfo/PersonalInfo/Address/Street">
         <div>
            <xforms:label>Street Address</xforms:label>
         </div>
         <xforms:hint>Enter Street Address</xforms:hint>
      </xforms:input>
      <br>
      <xforms:input class="City" id="city" 
                    ref="OrderInfo/PersonalInfo/Address/City">
         <xforms:label class="label">City</xforms:label>
         <xforms:hint>Enter City Name</xforms:hint>
      </xforms:input>
      <xforms:input class="State" id="state" 
                    ref="OrderInfo/PersonalInfo/Address/State">
         <xforms:label class="label">State</xforms:label>
         <xforms:hint>Enter State Initials</xforms:hint>
      </xforms:input>
      <xforms:input class="ZipCode" id="zipcode" 
                    ref="OrderInfo/PersonalInfo/Address/ZipCode">
         <xforms:label class="label">Zip Code</xforms:label>
         <xforms:hint>Enter The Zip Code</xforms:hint>
      </xforms:input>
   </div>
   <br>
   <div>
      <xforms:label class="label">Sub Total   $</xforms:label>
      <xforms:output class="Amount" id="subtotal" 
                     ref="OrderInfo/PriceInfo/SubTotal" />
      <br>
      <xforms:label class="label">Tax Amount $</xforms:label>
      <xforms:output class="Amount" id="taxtotal" 
                     ref="OrderInfo/PriceInfo/TaxTotal" />
      <br>
      <xforms:label class="label">Total       $</xforms:label>
      <xforms:output class="Amount" id="total" 
                     ref="OrderInfo/PriceInfo/Total" />
   </div>
   <br>
   <div>
      <xforms:label class="label">Shopping Cart</xforms:label>
      <xforms:repeat id="shoppingcart" 
                     nodeset="OrderInfo/ShoppingCart/ProductInfo">
         <xforms:output ref="Quantity" />
         <xforms:output ref="Description" />
         <xforms:output ref="UnitPrice" />
         <xforms:output ref="ItemTotal" />
      </xforms:repeat>
   </div>
   <br>
   <xforms:submit id="submit1">
      <xforms:label>Send Payment</xforms:label>
   </xforms:submit>
   <xforms:trigger>
      <xforms:label>Cancel</xforms:label>
         <xforms:action event="click" >
            <xforms:refresh ev:event="xforms:activate"/>
       </xforms:action> 
   </xforms:trigger>
  </xforms:group>
 </body>
</HTML>

Return to article

Appendix B: Tags mentioned in the main article, in alphabetical order

Appendix B1: action

Syntax:

<action>
       (Common Attributes)
       (Events)
</action>

Where it belongs: On the model, to encapsulate the actions.

Attributes:

According to the W3C XForms documentation, <action> "is used to group multiple actions." The list of actions should be listed on the element <action> rather than on the contained actions.

<trigger>
      <label>Clear</label>
      <action ev:event="xforms:activate">
            <resetInstance />
      </action>
</trigger>

The ev:event="xforms:activate" has to be inside the <action> tag. It does not work if used it in the resetInstance tag.

Appendix B2: bind

Syntax:

<bind 
  nodeset = binding-expression
  (model item properties )
  (Content)>
</bind>

Where it belongs: In the model.

Attributes:

  • nodeset: A binding expression that selects the set of nodes that this <bind> operates on.
  • Model item properties: See Appendix H.

According to the W3C XForms documentation, <bind> "operates on a nodeset selected from the instance data." <bind> is a key part of XForms. Its elements encode the model item properties that are applied to the nodesets. Each <bind> element selects a nodeset from the instance data, and applies the specified model item properties.

<bind ref="my:PersonalInfo/Address/Zip" required="true" />

Appendix B3: group

Syntax:

<group
      (single node binding attributes)
      (common attributes)>
      (XML/HTML)
</group>

Where it belongs: In the user interface, to arrange information.

Attributes:

The W3C XForms specification describes the <group> tag as "a container for defining a hierarchy of form controls." It is used to organize the data into a treelike form (given that data can be nested).

<group xmlns="http://www.w3.org/2002/01/XForms">
      <label>People List</label>
      <repeat id="lineset" nodeset="Customer/PersonalInfo">
            <group xmlns="http://www.w3.org/2002/01/XForms">
                  <group xmlns="http://www.w3.org/2002/01/XForms">
                        <p>      <output ref="Name/FirstName"></output>
                              <output ref="Name/MI"></output>
                              <output ref="Name/LastName"></output></p>
                        <p>      <output ref="Address/Street"></output>
                              <output ref="Address/HouseNumber"> </output></p>
                        <p>      <output ref="Address/City"></output>
                              <output ref="Address/State"></output>
                              <output ref="Address/Zip"></output></p>
                  </group>
            </group>
      </repeat>
</group>

The listing above shows how easy it is to organize the data. The first <group> encapsulates the information of all customers. The next sub-<group> holds the information for each customer entry.

Appendix B4: input

Syntax:

<input
      (Single node binding attributes)
      (Common attributes)
      (UI Common attributes)
      inputMode = xsd:string
      incremental>
     (label, (help|hint|alert|action|extension))
</input>

Where it belongs: In the user interface, to get data from the user.

Attributes:

  • nodeset binding attributes: See Appendix H.
  • Common attributes: See Appendix H.
  • UI common attributes: See Appendix H.
  • inputMode: Provides a hint to the user agent to select an appropriate input mode for the text input. It should be used as often as possible.
  • incremental: When true, this form control generates xforms-value-changing events.

According to the W3C XForms documentation, <input> "enables free-form data entry."

Figure A1. Input box
Input box

Appendix B5: instance

Syntax:

<instance 
       (Common Attributes)
       (Linking)
       schema = xsd:anyURI >
       (Any Content)
</instance>

Where it belongs: Within the model.

Attributes:

  • Common attributes: See Appendix H.
  • Linking: See Appendix H.
  • schema: Optional link to externally defined instance data.

According to the W3C XForms documentation, <instance> "contains a skeleton instance document that provides initial instance data." The data defined by this instance need not necessarily be implemented inline. It could be specified in an external URI.

<instance>
      <PersonalInfo>
            <Name>
                  <FirstName></FirstName>
                  <MI></MI>
                  <LastName></LastName>
            </Name>
            <Address>
                  <Zip></Zip>
                  <State></State>
                  <City></City>
                  <HouseNumber></HouseNumber>
                  <Street></Street>
            </Address>
            <Taxes>
                  <Amount></Amount>
                  <Rate></Rate>
                  <Pay></Pay>
            </Taxes>
      </PersonalInfo>
</instance>

The <instance> may specify the structure of the data only or may include initial values.

Appendix B6: model

Syntax:

<model
      (Common Attributes)
      functions = list of QNames>
      (elements)
</model>

Where it belongs: Head of HTML form.

Attributes:

  • functions: Optional list of XPath extension functions used by this XForms <model>.
  • Common attributes: See Appendix C.

According to the W3C XForms documentation, <model> is "used as a container for XForms elements defining the XForms model." <model> is one of the key tags of XForms and is necessary to complete an XForms document. You can add other tags (elements) that will complete the model. These tags are:

  • <instance> (this tag is required)
  • <schema>
  • <submission>
  • <bind>
  • <privacy>
  • Action event handlers
  • <extension>

This tag is explained in the following listing:

<model id="data" xmlns="http://www.w3.org/2002/01/xforms">
      <instance>
            <AddressInfo>
                  <Name>
                        <FirstName></FirstName>
                        <MI></MI>
                        <LastName></LastName>
                  </Name>
                  <Address>
                        <Zip></Zip>
                        <State></State>
                        <City></City>
                        <HouseNumber></HouseNumber>
                        <Street></Street>
                  </Address>
            </AddressInfo>
      </instance>
      <submission      action=
         "http://summer2/AddressServices/AddrServices.asmx/GetCustomer"
          method="post" replace="all" id="get" />
</model>

This example shows how to build a simple model. The AddressInfo is the structure of the data used on the form.

Appendix B7: output

Syntax:

<output
      (Common Attributes)
      (single node binding attributes)
      appearance >
      (Empty content)
</output>

Where it belongs: In the user interface, to display information.

Attributes:

  • Single node binding attributes: See Appendix H.
  • Common attributes: See Appendix H.
  • appearance: This form control does not use the UI common attributes group.

The W3C documentation provides the following description of <output>: "...renders a value from the instance data, but provides no means for entering or changing data." This tag is used for display purposes only.

Figure A2. Output box
Output box

Appendix B8: repeat

Syntax:

<repeat
     (node binding attributes)
     (common attributes)
     startIndex = xsd:positiveInteger : 1
     number = xsd:nonNegativeInteger >
     (XML/HTML)
</repeat>

Where it belongs: In the user interface, as a form control.

Attributes:

  • Nodeset binding attributes: See Appendix H.
  • Common attributes: See Appendix H.
  • startIndex: Indicates which starting element from the collection should be displayed; minimum value is 1.
  • number: Hint telling the XForms processor how many elements should be displayed.

According to the W3C XForms documentation, "<repeat> represents a repeating homogeneous collection -- in other words, a collection consisting entirely of like form controls." This tag is useful for displaying similar information (as in the data model) in an elegant way. It may look complicated but it is extremely easy to use.

<!--in user interface-->
<repeat id="lineset" nodeset="Customer/PersonalInfo">
            <p>      <output ref="Name/FirstName"></output>
                  <output ref="Name/MI"></output>
                  <output ref="Name/LastName"></output></p>
            <p>      <output ref="Address/Street"></output>
                  <output ref="Address/HouseNumber"></output></p>
            <p>      <output ref="Address/City"></output>
                  <output ref="Address/State"></output>
                  <output ref="Address/Zip"></output></p>
</repeat>

In the example above, you can see how easy it is to create a <repeat> structure. The structure is as follows:

  • Customer/PersonalInfo: Top node of the structure. Defined in the data model. Customer is the parent node, PersonalInfo is the child.
  • Name/(FirstName/MI/LastName) and Address/(Street/HouseNumber/City/State/Zip): Name and Address are children of PersonalInfo. They also have their own children.
<xforms:repeat id="shoppingcart" 
   nodeset="OrderInfo/ShoppingCart/ProductInfo">
      <xforms:output ref="Quantity"/> 
      <xforms:output ref="Description"/>
      <xforms:output ref="UnitPrice"/>
      <xforms:output ref="ItemTotal"/>
</xforms:repeat>
Figure A3. Our form, with repeat tags
The form, with repeat tags

Appendix B9: submission

Syntax:

<submission
       (Common Attributes) 
       (single node binding attributes)
       action = xsd:anyURI
       mediaTypeExtension = "none" | qname-but-not-ncname : "none"
       method = "post" | "get" | qname-but-not-ncname : "post"
       version = xsd:NMTOKEN
       indent = xsd:boolean
       encoding = xsd:string
       mediaType = xsd:string
       omitXMLDeclaration = xsd:boolean
       standalone = xsd:boolean
       CDATASectionElements = list of xsd:QName
       replace = "all" | "instance" | "none" | qname-but
       not-ncname : "all">
      (XForms Actions)
</submission>

Where it belongs: In the user interface as a control to the submit operations.

Attributes:

  • Common attributes: See Appendix H.
  • Single node binding attributes: See Appendix H.
  • action: Required destination for submitting instance data.
  • mediaTypeExtension: Optional information describing the serialization format. This is in addition to mediaType.
  • method: Optional indicator as to the protocol to be used to transmit the serialized instance data.
  • version: Corresponds to the version attribute of xsl:output.
  • indent: Corresponds to the indent attribute of xsl:output.
  • encoding: Corresponds to the encoding attribute of xsl:output.
  • mediaType: Corresponds to the media-type attribute of xsl:output.
  • omitXMLDeclaration: Corresponds to the omit-xml-declaration attribute of xsl:output.
  • standalone: Corresponds to the standalone attribute of xsl:output.
  • CDATASectionElements: Corresponds to the cdata-section-elements attribute of xsl:output.
  • replace: Specifies how the information returned after submit is applied.

According to the W3C XForms documentation, <submission> "encodes how, where, and what to submit." Many of these attributes are XSLT, but XSLT's doctype-system and doctype-public are not supported by XForms processing. This tag provides many parameters to control the mechanics of form submission.

<submission      action=
"http://summer2/AddressServices/AddrServices.asmx/GetCustomer"
 method="post" replace="all" id="get" />

The action indicates what to do, the method indicates how to do it, and the id specifies how to access it from the body.

Appendix B10: submit

Syntax:

<submit
      (Common Attributes)
      (single node binding attributes)
      (UI Common Attributes)
      submission >
      (label, (help|hint|alert|action|extension))
</submit>

Where it belongs: This tag is used within the body as a control to send data.

Attributes:

  • nodeset binding attributes: See Appendix H.
  • Common attributes: See Appendix H.
  • UI common attributes: See Appendix H.
  • submission: Required reference to submission element.

According to the W3C XForms documentation, <submit> "initiates submission of all or part of the instance data to which it is bound." <submit> has the same task as HTML's <submit>. It dispatches an xforms:activate event that is handled by the <submission> element. If this element is not specified in the <submit> tag, the first <submission> element specified in the document is used. Binding is not possible for this control.

Figure A4. Submit trigger
Submit trigger

Appendix B11: switch and case

Syntax:

<switch
     (common attributes)>
     [Case]
</switch>
<case
     (common attributes)
     selected = xsd:boolean>
     (XML)
</case>

Where they belong: In the user interface, as a UI selector.

Attributes:

  • Common attributes: See Appendix H.
  • selected: Optional selection status for the case.

According to the W3C XForms documentation, <switch> and <case> "allow the creation of user interfaces where the user interface can be varied based on user actions and events." <switch> is used when several alternatives have different corresponding actions.

<switch id="sw">
      <case id="in" selected="true">
            <input ref="yourname">
                  <label>Please tell me your name</label>
                  <action ev:event="activate">
                        <toggle case="out" />
                  </action>
            </input>
      </case>
      <case id="out" selected="false">
            <p>Hello <output ref="yourname"></output>
            <trigger id="editTrigger">
                  <label>Edit</label>
                  <action id="editAction" ev:event="activate">
                        <toggle case="in" />
                  </action>
            </trigger></p>
      </case>
</switch>

The listing above is a very simple example. The form asks for the name until the user inputs one. As soon as the user enters the name, the case of the switch changes and a greeting with the name of the user appears.

Appendix B12: trigger

Syntax:

<trigger
      (Common Attributes)
      (single node binding attributes)
      (UI Common Attributes)>
      label
</trigger>

Where it belongs: In the user interface, to display a trigger.

Attributes:

According to the W3C XForms documentation, <trigger> "allows for user-triggered actions." It is very similar to the HTML tag of the same name. This tag requires an <action> subelement to perform an action.

<trigger>
      <label>Clear</label>
      <action ev:event="activate">
            <resetInstance />
      </action>
</trigger>

This tag should have the <label> tag to indicate the label of the trigger.

Return to article

Appendix C: Common tags not mentioned in the main paper

Appendix C1: extension

Syntax:

<extension>
      (Content)
</extension >

Where it belongs: In the model.

According to the W3C XForms documentation, <extension> is "a container for application-specific extension elements from any namespace other than the XForms namespace." The processing of the elements is not specified with this tag. In the example below, RDF is the metadata and is attached to a different form of control.

<input ref="dataset/user/email" id="email-input">
      <label>Enter your email address</label>
      <extension>
            <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf- syntax-ns#">
                  <rdf:Description rdf:about="#email-input">
                        <my:addressBook>personal</my:addressBook>
                  </rdf:Description>
            </rdf:RDF>
      </extension>
</input>

Appendix C2: range

Syntax:

<range
      (single node binding attributes)
      (common attributes)
      (common UI)
      start = datavalue
      end = datavalue
      step = datavalue-difference>
      (label, (help|hint|alert|action|extension))
</range>

Where it belongs: This tag is used on the user interface to select a range of values.

Attributes:

  • Single node binding attributes: See Appendix H.
  • Common attributes: See Appendix H.
  • UI common attributes: See Appendix H.
  • start: For the lexical starting bound for the range.
  • end: For the ending bound for the range.
  • step: For incrementing or decrementing the valueFrom.

According to the W3C XForms documentation, <range> "allows selection from a continuous range of values." It only binds to certain data types. The input should be the same as the dataType. This tag can accomplish many different functions using its different attributes.

<range ref="/stats/balance" start="-2.0" end="2.0" stepSize="0.5">
      <label>Balance</label>
</range>

Appendix C3: select

Syntax:

<select
      (single node binding attributes)
      (common attributes)
      (common UI)
      incremental>
      (label, (choices|item|itemset), (help|hint|alert|action|extension))
</ select >

Where it belongs: In the user interface when a multiple selection from a list is needed.

Attributes:

  • Single node binding attributes: See Appendix H.
  • Common attributes: See Appendix H.
  • UI common attributes: See Appendix H.
  • incremental: When true, this form control generates xforms-value-changing events.

According to the W3C XForms documentation, <select> "allows the user to make multiple selections from a set of choices." This is very useful when the user must select multiple answers to a question or task. The tag must be bound to a simpleContent capable of holding sequences.

<select ref="my:icecream/my:flavors">
      <label>Flavors</label>
      <choices>
            <item>
                  <label>Vanilla</label>
                  <value>v</value>
            </item>
            <item>
                  <label>Strawberry</label>
                  <value>s</value>
            </item>
            <item>
                  <label>Chocolate</label>
                  <value>c</value>
            </item>
      </choices>
</select>

Appendix C4: select1

Syntax:

<select1
      (single node binding attributes)
      (common attributes)
      (common UI)
      selection = "open" | "closed" : "closed"
      incremental>
      (label, (choices|item|itemset), (help|hint|alert|action|extension))
</select1>

Where it belongs: In the user interface when a single selection from a list is needed.

Attributes:

  • Single node binding attributes: See Appendix H.
  • Common attributes: See Appendix H.
  • UI common attributes: See Appendix H.
  • selection: Attribute determining whether free entry is allowed in the list.
  • incremental: When true, this form control generates xforms-value-changing events.

According to the W3C XForms documentation, <select1> "allows the user to make a single selection from multiple choices." This is very useful when you need a form on which the user must select a single answer to a question or task. It binds to any simpleContent. For each option, a label must be present.

<select1 ref="my:icecream/my:flavor">
      <label>Flavor</label>
      <item>
            <label>Vanilla</label>
            <value>v</value>
      </item>
      <item>
            <label>Strawberry</label>
            <value>s</value>
      </item>
      <item>
            <label>Chocolate</label>
            <value>c</value>
      </item>
</select1>

Appendix C5: text area

Syntax:

<textarea
      (single node binding attributes)
      (common attributes)
      (common UI)
      incremental
      inputMode = xsd:string>
      (label, (help|hint|alert|action|extension))
</textarea>

Where it belongs: On the user interface, to write large amounts of data.

Attributes:

  • Single node binding attributes: See Appendix H.
  • Common attributes: See Appendix H.
  • UI common attributes: See Appendix H.
  • incremental: When true, this form control generates xforms-value-changing events.
  • InputMode: Provides a hint to the user to select an appropriate input mode for the text input. It should be used as often as possible.

According to the W3C XForms documentation, <textarea> "enables free-form data entry and is intended for use in entering multiline content." This is one of the XForms tags most similar to its HTML counterpart. With the XForms tag, you can select how much data is allowed, and perform other control operations as well.

<textarea ref="message/body">
      <label>Message Body</label>
      <hint>Enter the text of your message here</hint>
</textarea>

Return to article

Appendix D: Primitive functions supported by calculate

  • Basic arithmetic functions:
    • Addition (+)
    • Subtraction (-)
    • Multiplication (*)
    • Division (div or /)
  • boolean-from-string(string): Returns true if the string is equal to the string "true" and false if the string is equal to the string "false"; in all other cases, a fatal error is returned.
  • if (boolean, string1, string2): If the boolean evaluates to true, returns string1; otherwise, returns string2.
  • avg(nodeset): Returns the arithmetic average of the nodeset.
  • min(nodeset): Returns the smallest value in the nodeset.
  • max(nodeset): Returns the largest value in the nodeset.
  • count(nodeset): Returns the number of nodes within the nodeset.
  • count-non-empty(nodeset): Returns the number of non-empty nodes in the nodeset.
  • sum(nodeset): Returns the sum of the nodes within the nodeset.
  • cursor(string): The string parameter should be an id reference to a repeat statement. Cursor returns the current position of the repeat cursor.
  • property(string): The string parameter should be a valid XForms property; property returns the value of the XForms property.
  • now(): Returns the current date and time as a string.

Return to article

Appendix E: XForms constraints

Note: These XForms constraints usually are used as attributes within a <bind> tag.

  • type: Specifies the XSD/data type of data binding.
  • readOnly: Restricts the value so it can only be read and not modified.
  • required: Forces the user to input data in the field.
  • relevant: Defines the conditions when the data bind is applicable.
  • calculate: Binds the value to an expression (see Appendix D for a full list of legal functions that can be included in an expression).
  • isValid: according to the W3C XForms specification, "specifies a predicate that needs to be satisfied for the associated instance data node to be considered valid."
  • maxOccurs: For repeating structures, defines the maximum number of children allowed.
  • minOccurs: For repeating structures, defines the minimum number of children needed.

Return to article

Appendix F: Common child elements

The following child elements help add metadata with the form control tags:

  • label: Labels the form control.
  • help: Attaches additional help information with the form control that the user might find helpful when stuck or confused.
  • hint: Attaches a hint with the form control. Like help, but briefer.
  • alert: Provides a way to notify the user when an event occurs.
  • extension: Extends the XForms definition with a developer-created tag.

Return to article

Appendix G: XForms actions

  • dispatch: Dispatches an XML event to a target element. Two kinds of events can be dispatched: a predefined XForms event or a user-defined XForms event. However, the XForms processor only handles XForms events; user-defined events are ignored. Syntax is:

    <dispatch       name = name of the event to dispatch
                    target = id of the target element
                    bubbles = boolean of whether the event bubbles
                   cancelable = boolean of whether the event is cancelable />
  • refresh: Refreshes the XForms. Syntax is:

    <refresh/>
  • recalculate: Recalculates the fields that need to be recomputed. Syntax is:

    <recalculate/>
  • revalidate: Revalidates the instance data. Syntax is:

    <revalidate/>
  • setFocus: Sets the focus to the form control specified in idref. Syntax is:

    <setfocus idref = id of the form control to set the focus on />
  • submitInstance: Submits the instance data to the back end. This is the action that <submit> calls. Syntax is:

    <submitInstance submission = id of submission />
  • resetInstance: Resets the instance data to its default values. Syntax is:

    <resetInstance model = id of model />
  • setRepeatCursor: Sets the position of a repeat structure to a specified position. Syntax is:

    <setRepeatCursor repeat = id of repeat structure cursor = new position />
  • action: An event handler for XForms actions. Syntax is:

    <action>
                Set of XForms actions
    </action>

For the following actions, refer to the XForms specification for details:

  • loadURI: Traverses the specified XLink.
  • setValue: Sets the value of an instance node.
  • insert: Inserts new entries in a nodeset.
  • delete: Deletes a node from a nodeset.
  • toggle: Selects one case from a set of cases; used in the <switch> tag.
  • script: Uses developer-set event handlers from other scripting languages.
  • message: Displays a message.

Return to article

Appendix H: Commonly used attributes

  • Common attribute:
    • anyAttribute: Foreign attributes are allowed on all XForms elements. A containing document language must include an attribute of type xsd:ID on each XForms element.
  • Linking attribute:
    • src: Assigns a URI to be automatically retrieved.
  • Single node binding attributes:
    • ref: Binding expression.
    • model: XForms model selector.
    • bind: Reference to a <bind> element.
  • Nodeset binding attributes:
    • nodeset: Binding expression.
    • model: XForms model selector.
    • bind: Reference to a bind element.
  • UI common attributes:
    • help: Attaches help information to a form control.
    • hint: Attaches hint information to a form control.
    • alert: Attaches alert or error information to a form control.

Return to article