Sets the choices that are displayed by a checkgroup or list when the user can select one or more of the choices. When the form is processed, an individual check or cell item is automatically generated to represent each choice.
The xforms:select option has two different syntaxes, depending on whether the choices are included in the option itself, or whether the choices are included in the data model and linked by the option.
If you want to include the choices in the option itself, use the following syntax:
<xforms:select single_node_binding appearance="style">
<xforms:label>label text</xforms:label>
<xforms:item1>
<xforms:label>label for choice</xforms:label>
<xforms:value>value for choice</xforms:value>
<xforms:extension>XFDL Options</xforms:extension>
</xforms:item1>
...
<xforms:itemn>
...
<xforms:itemn>
Alert Setting
Hint Setting
Help Setting
</xforms:select>
Parameter | Type | Description |
---|---|---|
single node binding | string | see Single node binding. |
style | string | sets to one of the following values:
Default: compact. |
label text | string | sets the text for a label that is displayed
at the top of the checkgroup. Leave this blank
to display no label. If the item also has a label option, it will override this setting. |
label for choice | string | sets the text that is displayed for the choice. |
value for choice | string | sets the value that is stored if the user selects this choice. |
XFDL Options | XFDL options | adds specific XFDL options to the item represented by the choice. For example, you might want to add a type option to the choices in a list, so that the cells that are generated by those choices trigger actions. |
Hint, Help Setting | metadata | see Metadata sub-options. |
If you want to include the choices in the data model, use the following syntax:
<xforms:select single_node_binding appearance="full">
<xforms:label>label text</xforms:label>
<xforms:itemset nodeset="XPath to choices">
<xforms:label ref="XPath to label text"/>
<xforms:value ref="."></xforms:value>
<xforms:extension>XFDL Options</xforms:extension>
</xforms:itemset>
Hint Setting
Help Setting
Alert Setting
</xforms:select>
Parameter | Type | Description |
---|---|---|
single node binding | string | see Single node binding. |
label text | string | sets the text for a label that is displayed
at the top of the checkgroup. Leave this blank to display no label. |
XPath to choices | string | an XPath reference to the elements in
the data model that provide the choices. This defines the set of item’s
that the checkgroup or list displays
as choices. This reference is relative to the XPath to element reference.
For example, your data model may contain the following elements that represent the choices for your item: In this case, you would reference those choices as: |
XPath to label text | string | an XPath reference to the label text
for each choice. This text is included in your data model as attributes
on the data elements that contain your choices. This reference is
relative to the XPath to choices reference. For example, your data model may contain the following elements that represent the choices for your checkgroup: In this case, your would reference the show attributes that contain the text that describes that element, as shown: |
XFDL Options | XFDL options | adds specific XFDL options to all items represented by the itemset. For example, if you are creating a checkgroup, you might want to set the itemlocation for all items in the set, so that they are spaced horizontally rather than vertically. |
Hint, Help Setting | metadata | see Metadata sub-options. |
checkgroup, list
The following code creates a checkgroup with three choices: US Dollars, CDN Dollars, and Euro. The choices themselves are defined within the xforms:select option.
<checkgroup sid="currency">
<xforms:select ref="currency" appearance="full">
<xforms:label
>Select the currencies you accept:</xforms:label>
<xforms:item>
<xforms:label>US Dollars</xforms:label>
<xforms:value>USD</xforms:value>
</xforms:item>
<xforms:item>
<xforms:label>CDN Dollars</xforms:label>
<xforms:value>CDN</xforms:value>
</xforms:item>
<xforms:item>
<xforms:label>Euro</xforms:label>
<xforms:value>Euro</xforms:value>
</xforms:item>
</xforms:select>
</checkgroup>
Alternatively, you could create the choices in your data model as follows:
<xforms:instance xmlns="" id="currency">
<data>
<currency/>
<choice show="US Dollars">USD</choice>
<choice show="CDN Dollars">CDN</choice>
<choice show="Euros">Euro</choice>
</data>
</xforms:instance>
In this case, you would use the xforms:select option to link to those choices, as illustrated by the following checkgroup:
<checkgroup sid="currency">
<xforms:select ref="currency" appearance="full">
<xforms:label
>Select the currencies you accept:</xforms:label>
<xforms:itemset nodeset="instance('currency')/choice">
<xforms:label ref="@show"></xforms:label>
<xforms:value ref="."></xforms:value>
</xforms:itemset>
</xforms:select>
</checkgroup>
<xforms:item>
<xforms:label>US Dollars</xforms:label>
<xforms:value>USD</xforms:value>
<xforms:extension>
<type>link</type>
<url>http://www.ibm.myserver.com/mypage.htm</url>
</xforms:extension>
</xforms:item>
<itemlocation>
<after compute="itemprevious"/>
</itemlocation>
<xforms:item>
<xforms:label>Save</xforms:label>
<xforms:value>Save</xforms:value>
<xforms:extension>
<type>saveas</type>
</xforms:extension>
</xforms:item>
<xforms:item>
<xforms:label>Submit</xforms:label>
<xforms:value>Submit</xforms:value>
<xforms:extension>
<type>submit</type>
</xforms:extension>
</xforms:item>
For example, you might have a data model that sets a full text label for the choices, but uses an abbreviated value. The following instance shows this, using the show attribute to set the xforms:label and the contents of each element to set the xforms:value:
<xforms:instance id="currency">
<data>
<choice show="US Dollars">USD</choice>
<choice show="CDN Dollars">CDN</choice>
<choice show="Euros">Euro</choice>
</data>
</xforms:instance>
In this case, you might want to display the full text label even after a choice is selected. You can do this by using xforms:extension to add a value to each item in the set. You can then set the value to compute its contents to equal the label, which is populated with the full text description. The following sample shows this:
<checkgroup sid="currency">
<xforms:select ref="currency" appearance="full">
<xforms:label
>Select the currencies you accept:</xforms:label>
<xforms:itemset nodeset="instance('currency')/choice">
<xforms:label ref="@show"></xforms:label>
<xforms:value ref="."></xforms:value>
<xforms:extension>
<value compute="label"/>
</xforms:extension>
</xforms:itemset>
</xforms:select>
</checkgroup>