Example

The following schema represents a customer and account:

bank 
    *customer 
        age 
        *account 
            baseInterestRate 
            actualInterestRate

In this example the bank, customer and account are composite elements. Customer and account are repeating elements. The age is of type int and baseInterestRate and actualInterestRate are of type float. The bank can have many customers and each customer can have multiple accounts. Each account has a base interest rate and actual interest rate. Actual interest rate is a computed element and depends on base interest rate and customer’s age. Assume expression for acualInterestRate is baseInterestRate + (age >= 60 ? 0.5:0.0). At runtime expression manager is provided following values for age and baseInterestRate:

age: [20, 61] 
baseInterestRate: [[7, 8][7.5, 8, 8.5]]

After flattening these variables, the following two-dimensional array is created:

20 7 
20 8 
61 7.5 
61 8 
61 8.5

Age elements are repeated multiple times according to number of elements in baseInterestRates. Expression is evaluated for each of these rows. After evaluating expressions, results are arranged in the same hierarchy as the input variable baseInterestRate. The variable with most number of repeating levels is considered because expression is always at the deepest level and does not use variables which are further down in hierarchy. API returns the result as [[7, 8][8, 8.5, 9]].

// Ethnio survey code removed