XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
108
<subform name="Receipt" …>
<field name="Discount"…> … </field>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …>
<calculate>
<script>(Units * Unit_Price) * (1 - (Discount/100.0))</script>
</calculate>
</field>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …>
<calculate>
<script>(Units * Unit_Price) * (1 - (Discount/100.0))</script>
</calculate>
</field>
</subform>
</template>
</xdp>
Inferred Index for Ancestors of the Container
The same logic that is used at the level of the script's container also applies to ancestors or siblings of
ancestors which match an unqualified SOM expression. In each case, the target's index defaults to the
index of the ancestor or ancestor's sibling at the same level of the hierarchy. The result of this rule is that if
a cell in a table contains a SOM expression that references another table, the SOM expression defaults to
referencing the corresponding cell in the other table. For example, a form has been created to calculate
trip times. In one field the user enters his estimated average driving speed in kilometres per hour. The form
also displays two 5 by 5 tables. The first table shows distances between cities in kilometres and the second
shows estimated travel times between the same cities in hours. The content of each cell in the second
table is calculated based upon the corresponding cell in the first table. The template contains:
<xdp …>
<template …>
<subform name="Trip">
<field name="Speed" …> … </field>
<subform name="Distance" …>
<subform name="Distances" …>
<occur min="5" max="5" />
<field name="Cell"…> … </field>
<field name="Cell"…> … </field>
<field name="Cell"…> … </field>
<field name="Cell"…> … </field>
<field name="Cell"…> … </field>
</subform>
</subform>
<subform name="Time" …>
<subform name="Times" …>
<occur min="5" max="5" />
<field name="Cell"…>
<calculate>
<script>Distance.Distances.Cell /
Speed</script>
Home Index Bookmark Pages
Pages: Home Index All Pages