Rational Developer for System z

Cardinality: optional, repeating and mandatory elements

This topic introduces the concept of optional, repeating, and mandatory elements.

Elements

The number of occurrences of an element can be controlled using the properties Min Occurs and Max Occurs. Using these properties, an element can be defined as mandatory, optional or repeating.
  • A mandatory element has Min Occurs >= 1. A mandatory element must occur at least once in an input message.
  • An optional element has Min Occurs = 0. An optional element can be omitted from the input message.
  • A repeating element normally has Max Occurs > 1. It can occur more than once in the input message, and all the occurrences must appear together without any other elements between them.

If a complex type or a group contains two (or more) members which refer to the same global element, the second reference is a duplicate. This is different from a repeating element, because the two references will usually be separated by other members of the type or group. In the input message, the second occurrence will usually not appear immediately after the first occurrence. Duplicate element references are not allowed within types and groups which have compositions of Choice, OrderedSet or UnorderedSet.

Attributes

The number of occurrences of an attribute can be controlled by setting it to required, optional or prohibited.

  • A required attribute is similar to a mandatory element - it must occur in the input message.
  • An optional attribute is similar to an optional element - it can be omitted from the input message.
  • A prohibited attribute must not appear in the input message.

Feedback