The setvalue element
This action explicitly sets the value of the specified instance data node. This action has no effect if the Single Node Binding does not select an instance data node or if a readonly instance data node is selected. An xforms-binding-exception occurs if the Single Node Binding indicates a node whose content is not simpleContent (i.e., a node that has element children).
The element content of setvalue specifies the literal value to set; this is an alternative to specifying a computed value via attribute value. If neither a value attribute nor text content are present, the effect is to set the value of the selected node to the empty string (""). If both are present, the value attribute is used.
Example
XML | Copy Code |
---|---|
<xforms:setvalue ref="availableColors" ev:event="xforms-ready">Red Blue Green</xforms:setvalue> |
Attributes
Name | Required / optional | Description |
---|---|---|
value | optional | Attribute containing an XPath expression to evaluate, with the result stored in the selected instance data node. The evaluation context for this XPath expression is the result from the Single Node Binding. To obtain the value, the result of the expression is processed as if by call to the XPath string() function. An empty string is used if the XPath evaluation fails. |
Single Node Binding | required | One or more attributes from the Single Node Binding Attributes group (ref, model, bind). |
Common Attributes | optional | Any attribute from the Common Attributes collection (e.g. id). |
XML Events | optional | Any attribute from the XML Events collection (e.g. ev:event) |
Common Action Attributes | optional | Any attribute from the Common Action Attributes collection (if or while) |
Content
The setvalue element does not allow child elements, only inline text content.
Specification
Link to the XForms specification: the setvalue element.