Bind function

From W3C XForms Group Wiki (Public)

MarkBirbeck to start.

For non-model binding expressions (UI bindings/actions)

Original text from Peter Nunn:

One issue I frequently come up against is the verbosity of the xpath functions in the setvalue expression. I have prototyped and implemented an xforms extension function called bind(IDREF) that considerably reduces the amount of xpath code that needs to be entered.

The suggested function has the following form:

node-set bind(idref)

The function returns a nodeset that is the product of the evaluaion of a bind whose id is idref. If the node-set referenced by the id-ref contains a reference to an xpath containing a circular reference then an xforms-binding-error event should be raised.

Here is a sample use-case:

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns=""
    <title>Bind Extension Function</title>

    <xforms:model functions="bind">
        <data xmlns="">
      <xforms:bind id="bindColor" nodeset="//color" />
      <xforms:bind id="bindSelectedColor" nodeset="//selected-color" />
    <xforms:repeat bind="bindColor" id="rptColors">
      <xforms:output ref=".">
        <xforms:label>Select Color</xforms:label>
        <xforms:setvalue bind="bindSelectedColor"
                         ev:event="DOMActivate" />
    <xforms:output bind="bindSelectedColor">
      <xforms:label>Selected Color:</xforms:label>

While this is a relatively simple example, when really complex forms are developed complex xpath statements that refer to a common node-set the resulting xforms are much simpler to maintain and less prone to error.