Skip to content

Instantly share code, notes, and snippets.

@olafveerman
Created March 5, 2013 12:25
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 olafveerman/5089981 to your computer and use it in GitHub Desktop.
Save olafveerman/5089981 to your computer and use it in GitHub Desktop.
XForm - constraint based on answer of previous question
<?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:orx="http://openrosa.org/xforms/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>constraint</h:title>
<model>
<instance>
<constraint id="constraint">
<age/>
<min_years_smoked/>
<years_smoked/>
<meta>
<instanceID/>
</meta>
</constraint>
</instance>
<bind constraint=".&gt;= 12 and .&lt;=100" nodeset="/constraint/age" type="int"/>
<bind calculate=" /constraint/age - 12" nodeset="/constraint/min_years_smoked" type="string"/>
<bind constraint=".&lt;= /constraint/min_years_smoked and .&lt;= 65" nodeset="/constraint/years_smoked" type="int"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/constraint/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/constraint/age">
<label>How old are you?</label>
</input>
<input ref="/constraint/years_smoked">
<label>How many years have you smoked</label>
</input>
</h:body>
</h:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment