Skip to content

Instantly share code, notes, and snippets.

@avernet
Created March 31, 2015 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avernet/8248fc9d960e050e18a9 to your computer and use it in GitHub Desktop.
Save avernet/8248fc9d960e050e18a9 to your computer and use it in GitHub Desktop.
index() and repeat with bind
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:idc="http://www.inventivedesigners.com/xbl"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:saxon="http://saxon.sf.net/">
<xhtml:head>
<xhtml:meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<xhtml:title>Test</xhtml:title>
<xf:model id="m-default">
<xf:instance id="i-default">
<data xmlns="">
<repeat>
<id>1</id>
</repeat>
</data>
</xf:instance>
<xf:instance id="i-counter">
<form xmlns="">
<counter>1</counter>
</form>
</xf:instance>
<!-- bindings -->
<xf:bind ref="repeat" id="repeat-bind"/>
</xf:model>
</xhtml:head>
<xhtml:body style="width: 80%; margin-left: auto; margin-right: auto;">
<xhtml:table style="border: 1px solid black; margin-top: 50px;">
<xhtml:tbody>
<xf:repeat id="my_repeat" bind="repeat-bind">
<!--<xf:repeat id="my_repeat" ref="repeat">-->
<xhtml:tr>
<xhtml:td>
<xf:output ref="id"/>
</xhtml:td>
</xhtml:tr>
</xf:repeat>
</xhtml:tbody>
</xhtml:table>
<xf:trigger>
<xf:label>Insert</xf:label>
<xf:action ev:event="DOMActivate">
<xf:setvalue ref="instance('i-counter')/counter" value="number(.) + 1"/>
<xf:insert ref="repeat" at="index('my_repeat')" position="after" />
<xf:setvalue ref="repeat[last()]/id" value="instance('i-counter')/counter"/>
</xf:action>
</xf:trigger>
<xf:output value="index('my_repeat')"/>
<fr:xforms-inspector/>
</xhtml:body>
</xhtml:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment