Skip to content

Instantly share code, notes, and snippets.

@ukanga
Last active August 28, 2018 06:40
Show Gist options
  • Select an option

  • Save ukanga/da9c0f8d378470e12b69e4a7b2880feb to your computer and use it in GitHub Desktop.

Select an option

Save ukanga/da9c0f8d378470e12b69e4a7b2880feb to your computer and use it in GitHub Desktop.
XForm XML for loop with relative paths
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:odk="http://www.opendatakit.org/xforms" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>For loop with relative path</h:title>
<model>
<instance>
<forloop id="for_loop_w_relative_paths">
<for-block jr:template="">
<input/>
<done/>
</for-block>
<meta>
<instanceID/>
</meta>
</forloop>
</instance>
<bind nodeset="/forloop/for-block/input" relevant="( ../done ='no')" type="string"/>
<bind nodeset="/forloop/for-block/done" type="string"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/forloop/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<group ref="/forloop/for-block">
<label>Oh HAI</label>
<repeat nodeset="/forloop/for-block">
<input ref="/forloop/for-block/input">
<label>HI HI</label>
</input>
<input ref="/forloop/for-block/done">
<label>DONE?</label>
</input>
</repeat>
</group>
</h:body>
</h:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment