Capturing Composite Data

We have seen previously that it is possible to capture relationships in IEG. The combination of the Relationship entity and the RelationshipPage provide a convenient mechanism to capture the relationships between the people in a household. The relationship between people in a household is only one form of relationship. IEG supports other types of relationships. IEG and the DS allow entities to be nested creating a parent child relationship. This can be seen in the example where there is a requirement to capture the incomes for the people in a household. The Income entity is defined as any other entity is defined. It is nested in the Person entity by referencing it in a sequence, as the following sample code snippet shows:

Figure 1. Parent/Child Schema
<xsd:element name="Person">
  <xsd:complexType>
    <xsd:sequence minOccurs="0">
      <xsd:element ref="Income" minOccurs="0"
        maxOccurs="unbounded" />
    </xsd:sequence>
    ...
    <xsd:attribute name="hasIncome" type="IEG_BOOLEAN"
      default="false"/>
  </xsd:complexType>
  ...
</xsd:element>
<xsd:element name="Income">
  <xsd:complexType>
    <xsd:attribute name="type" type="IEG_STRING" />
    <xsd:attribute name="amount" type="IEG_MONEY" />
  </xsd:complexType>
</xsd:element>

Income information can then be gathered for people in a household by looping over every person that has income. The loop criteria will use a "hasIncome" boolean question that will be asked while gathering the details for each person. A page within the loop can be mapped to the Income entity thus creating the nested relationship, as shown below:

Figure 2. Creating Nested Entities
<loop loop-type="for-each" entity="Person"
        criteria="hasIncome==true">
  <loop loop-type="while" loop-expression="hasMoreIncome" 
          entity="Income">
    <question-page id="IncomePage" entity="Income"
    ...