Repeating Elements

It is common in XSD to specify that elements within a composite group can occur a multiple number of times. For example:

   <xsd:complexType name="Name">
      <xsd:sequence>
         <xsd:element name="givenName" type="xsd:string "/>
         <xsd:element name="initial" type="xsd:string"/>
         <xsd:element name="familyName" type="xsd:string" maxOccurs="2"/>
      </xsd:sequence>
   </xsd:complexType>

In this case, the familyName element may occur one or two times. (If minOccurs is absent, its default value is 1.) X.694 specifies that a SEQUENCE OF type be formed for this element and then the element renamed to familyName-list to reference this element. The C code produced by this transformation is as follows:

   typedef struct EXTERN Name {
      const OSUTF8CHAR* givenName;
      const OSUTF8CHAR* initial;
      struct {
         OSUINT32 n;
         const OSUTF8CHAR* elem[2];
      } familyName_list;
   } Name;

In this case, an array was used to represent familyName_list. In others, a linked list might be used to represent the repeating item.