Next: , Up: Program XML   [Contents][Index]


7.2.1 Defining Groups

A group organizes and relates entities. If given a ‘@title’, a header will be displayed above the group with that title. A group may optionally be given a unique identifier ‘@id’, which is useful for debugging and scripting; any such identifier should be snake_case.

  <group title="Foo Group">
    <question id="question_1" ... />
    <question id="question_2" ... />
  </group>

Figure 7.1: Defining a simple group with a title

Groups can be independently styled in a number of different ways to provide different data representations (see Group Styles). Style is optional—the ‘default’ group displays only the first index of each entity. Further styling can be done using CSS using ‘@class’.

All questions within a group share the same number of indexes; this is accomplished by monitoring the group leader. By default, the leader is the first indexable entity in the group (question, answer, or display); this can be overridden with the ‘@indexedBy’ attribute. This attribute is only practically meaningful if the chosen group style supports indexes (see Group Styles).

  <group id="leader_override" indexedBy="question_2" style="tabbed">
    <question id="question_1" ... />
    <question id="question_2" ... />
  </group>

Figure 7.2: Overriding group leader using ‘@indexedBy

Some group styles allow the user to add indexes; set ‘@locked’ to ‘true’ to suppress this feature.

7.2.1.1 Linking Groups

Data collection for similar entities may span multiple steps or groups; for example, one group may allow the user to define their risk locations, and a future group may ask for additional information for each of those locations. To have all entities within each of those groups share index length, they may be linked.

A group link is an arbitrary name given to a set of groups. Each group that wants to be part of the same link must set ‘@link’ to the same string. The name of the link does not matter—it is not a reference to a group ‘@id’.

  <group id="location" link="locations" style="tabbed">
    <question id="address" ... />
    <question id="city" ... />
  </group>

  <group id="underwriting" link="locations" style="tabbed">
    <question id="diving_board" ... />
    <question id="rabid_dog" ... />
  </group>

Figure 7.3: Linking groups using ‘@link

In Figure 7.3, each question in location and underwriting will have the same number of indexes—any time a new index is added to location, underwriting questions too will gain another index and vice versa. There is no limit to the number of groups that can share the same link.

Linked groups are implemented such that the union of all fields in each of the groups of a given link are assigned to each of the individual groups. When the leader of any group changes, a new index is initialized for each group field, which (in the case of linked groups) is comprised of all fields in the link.


Next: , Up: Program XML   [Contents][Index]