Skip to content

Instantly share code, notes, and snippets.

@ebruchez ebruchez/sums.xhtml
Last active Dec 21, 2015

What would you like to do?
<xf:model xxf:expose-xpath-types="true">
<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: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>

This comment has been minimized.

Copy link

dmccreary commented Aug 29, 2013

Nice example of using a predicate to check the validity of inputs in a calculation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.