Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save ukanga/6f175ef659b82bbbb77383df60457209 to your computer and use it in GitHub Desktop.
XForm XML 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>Relative Paths in repeats</h:title>
<model>
<instance>
<data id="relative_paths">
<Z/>
<section jr:template="">
<AA/>
<A/>
<B/>
<note1/>
</section>
<section2 jr:template="">
<C/>
<sectiona>
<D/>
<E/>
<note2/>
</sectiona>
<note3/>
</section2>
<section3 jr:template="">
<FF/>
<F/>
<sectionb>
<G/>
<H/>
<note4/>
</sectionb>
<sectionc jr:template="">
<I/>
<J/>
<K/>
<L/>
<note5/>
<note6/>
</sectionc>
<note7/>
<sectiond>
<M/>
<N/>
<O/>
<note8/>
</sectiond>
<note9/>
</section3>
<meta>
<instanceID/>
</meta>
</data>
</instance>
<bind nodeset="/data/Z" type="string"/>
<bind nodeset="/data/section/AA" type="string"/>
<bind nodeset="/data/section/A" type="string"/>
<bind nodeset="/data/section/B" relevant=" ../A ='oat'" type="string"/>
<bind nodeset="/data/section/note1" readonly="true()" type="string"/>
<bind nodeset="/data/section2/C" type="string"/>
<bind nodeset="/data/section2/sectiona/D" type="string"/>
<bind nodeset="/data/section2/sectiona/E" relevant=" ../D ='oat'" type="string"/>
<bind nodeset="/data/section2/sectiona/note2" readonly="true()" type="string"/>
<bind nodeset="/data/section2/note3" readonly="true()" type="string"/>
<bind nodeset="/data/section3/FF" type="string"/>
<bind nodeset="/data/section3/F" type="string"/>
<bind nodeset="/data/section3/sectionb/G" type="string"/>
<bind nodeset="/data/section3/sectionb/H" relevant=" ../G ='oat'" type="string"/>
<bind nodeset="/data/section3/sectionb/note4" readonly="true()" type="string"/>
<bind nodeset="/data/section3/sectionc/I" type="string"/>
<bind nodeset="/data/section3/sectionc/J" relevant=" ../I ='oat'" type="string"/>
<bind nodeset="/data/section3/sectionc/K" relevant=" ../../F ='oat'" type="string"/>
<bind nodeset="/data/section3/sectionc/L" relevant=" ../../sectionb/G ='oat'" type="string"/>
<bind nodeset="/data/section3/sectionc/note5" readonly="true()" type="string"/>
<bind nodeset="/data/section3/sectionc/note6" readonly="true()" type="string"/>
<bind nodeset="/data/section3/note7" readonly="true()" type="string"/>
<bind nodeset="/data/section3/sectiond/M" type="string"/>
<bind nodeset="/data/section3/sectiond/N" relevant=" ../../sectionb/G ='oat'" type="string"/>
<bind nodeset="/data/section3/sectiond/O" relevant=" ../M ='oat'" type="string"/>
<bind nodeset="/data/section3/sectiond/note8" readonly="true()" type="string"/>
<bind nodeset="/data/section3/note9" readonly="true()" type="string"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/data/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/data/Z">
<label>Fruit</label>
</input>
<group ref="/data/section">
<label>Section</label>
<repeat nodeset="/data/section">
<input ref="/data/section/AA">
<label>Anything really</label>
</input>
<input ref="/data/section/A">
<label>A oat</label>
</input>
<input ref="/data/section/B">
<label> B w <output value=" ../A "/> </label></input>
<input ref="/data/section/note1">
<label> Noted <output value=" ../AA "/> w <output value=" ../A "/> </label></input>
</repeat>
</group>
<group ref="/data/section2">
<label>Section 2</label>
<repeat nodeset="/data/section2">
<input ref="/data/section2/C">
<label>C</label>
</input>
<group ref="/data/section2/sectiona">
<label>Section A</label>
<input ref="/data/section2/sectiona/D">
<label>D oat</label>
</input>
<input ref="/data/section2/sectiona/E">
<label> E w <output value=" /data/Z "/> </label></input>
<input ref="/data/section2/sectiona/note2">
<label> Noted <output value=" ../../C "/> w <output value=" ../E "/> </label></input>
</group>
<input ref="/data/section2/note3">
<label> Noted <output value=" ../C "/> w <output value=" ../sectiona/E "/> </label></input>
</repeat>
</group>
<group ref="/data/section3">
<label>Section 3</label>
<repeat nodeset="/data/section3">
<input ref="/data/section3/FF">
<label>F any text</label>
</input>
<input ref="/data/section3/F">
<label>F oat</label>
</input>
<group ref="/data/section3/sectionb">
<label>Section B</label>
<input ref="/data/section3/sectionb/G">
<label>G oat</label>
</input>
<input ref="/data/section3/sectionb/H">
<label> H w <output value=" /data/Z "/> </label></input>
<input ref="/data/section3/sectionb/note4">
<label> Noted <output value=" ../H "/> w <output value=" /data/Z "/> </label></input>
</group>
<group ref="/data/section3/sectionc">
<label>Section B</label>
<repeat nodeset="/data/section3/sectionc">
<input ref="/data/section3/sectionc/I">
<label>I</label>
</input>
<input ref="/data/section3/sectionc/J">
<label> J w <output value=" /data/Z "/> </label></input>
<input ref="/data/section3/sectionc/K">
<label> K w <output value=" /data/Z "/> </label></input>
<input ref="/data/section3/sectionc/L">
<label> K w <output value=" /data/Z "/> </label></input>
<input ref="/data/section3/sectionc/note5">
<label> Noted <output value=" ../../FF "/> w <output value=" ../../sectionb/H "/> </label></input>
<input ref="/data/section3/sectionc/note6">
<label> JKL #<output value=" ../J "/>#<output value=" ../K "/>#<output value=" ../L "/> </label></input>
</repeat>
</group>
<input ref="/data/section3/note7">
<label> Noted <output value=" ../FF "/> w <output value=" ../sectionb/H "/> </label></input>
<group ref="/data/section3/sectiond">
<label>Section D</label>
<input ref="/data/section3/sectiond/M">
<label>M oat</label>
</input>
<input ref="/data/section3/sectiond/N">
<label> N w <output value=" /data/Z "/> </label></input>
<input ref="/data/section3/sectiond/O">
<label> O w <output value=" /data/Z "/> </label></input>
<input ref="/data/section3/sectiond/note8">
<label> NO #<output value=" ../N "/> #<output value=" ../O "/> </label></input>
</group>
<input ref="/data/section3/note9">
<label><output value=" ../FF "/><output value=" ../sectionb/H "/>
<output value=" ../sectiond/N "/><output value=" ../sectiond/N "/>
</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