Last active
December 21, 2015 02:19
-
-
Save ebruchez/6234199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xh:html | |
xmlns:xh="http://www.w3.org/1999/xhtml" | |
xmlns:xf="http://www.w3.org/2002/xforms" | |
xmlns:xxf="http://orbeon.org/oxf/xml/xforms" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |
<xh:head> | |
<xf:model xxf:expose-xpath-types="true"> | |
<xf:instance> | |
<data> | |
<a/> | |
<b/> | |
<c/> | |
<sum1/> | |
<sum2/> | |
</data> | |
</xf:instance> | |
<xf:bind ref="a | b | c | sum2" type="xs:decimal"/> | |
<xf:bind ref="sum1" type="xf:decimal"/> | |
<xf:bind ref="sum1" calculate="sum((../a, ../b, ../c))"/> | |
<xf:bind ref="sum2" calculate="sum((../a, ../b, ../c)[string() castable as xs:decimal], 0.0)"/> | |
</xf:model> | |
</xh:head> | |
<xh:body> | |
<xf:input ref="a"/> | |
<xf:input ref="b"/> | |
<xf:input ref="c"/> | |
<xf:output ref="sum1"><xf:label>Sum only if all values are correct:</xf:label></xf:output> | |
<xf:output ref="sum2"><xf:label>Sum all correct values and ignore others:</xf:label></xf:output> | |
</xh:body> | |
</xh:html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice example of using a predicate to check the validity of inputs in a calculation!