MarkBirbeck to start.
For non-model binding expressions (UI bindings/actions)
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:
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xml:lang="en"> <head> <title>Bind Extension Function</title> <xforms:model functions="bind"> <xforms:instance> <data xmlns=""> <color>red</color> <color>blue</color> <color>green</color> <selected-color></selected-color> </data> </xforms:instance> <xforms:bind id="bindColor" nodeset="//color" /> <xforms:bind id="bindSelectedColor" nodeset="//selected-color" /> </xforms:model> </head> <body> <xforms:repeat bind="bindColor" id="rptColors"> <xforms:output ref="."> <xforms:label>Color:</xforms:label> </xforms:output> <xforms:trigger> <xforms:label>Select Color</xforms:label> <xforms:setvalue bind="bindSelectedColor" value="bind('bindColor')[index('rptColors')]" ev:event="DOMActivate" /> </xforms:trigger> </xforms:repeat> <xforms:output bind="bindSelectedColor"> <xforms:label>Selected Color:</xforms:label> </xforms:output> </body> </html>
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.