A <Derivation> expression is similar to a <Default> expression except that it always calculates a value for the field, even if the field already has a non-null value. This is typically used to display a field whose value is a permutation of another field’s value. This is a valuable design feature if the resource attribute value is encoded and would not be obvious to the user.
The following example shows a field definition that uses conditional logic to map one set of values into another set.
<Field name=’location’ prompt=’Location’> <Display class=’Text’/> <Derivation> <switch> <ref>accounts[Oracle].locCode</ref> <case> <s>AUS</s> <s>Austin</s> </case> <case> <s>HOU</s> <s>Houston</s> </case> <case> <s>DAL</s> <s>Dallas</s> </case> <case default=’true’> <s>unknown</s> </case> </switch> </Derivation> </Field>
The <Derivation> element is part of the Form XML language that can contain an expression. When this field is processed, the expression in the <Derivation> element is evaluated to determine the value to be displayed for this field.
In the preceding example, the value of the resource account attribute accounts[Oracle].locCode is compared to the first value in each case expression. If a match is found, the result of the switch expression is the second value in the matching case expression.If no matches are found, the result of the switch is the value within the default case.