OCCURS … DEPENDING ON Clause
The COBOL OCCURS … DEPENDING ON clause defines a repeating data element whose number of occurrences are determined by a numeric item. The Plug-in converts this type of element to a repeating element in the XSD.
The syntax of the OCCURS ... DEPENDING clause is as follows:
OCCURS min TO max TIMES DEPENDING ON object
In the XSD schema, items with OCCURS ... DEPENDING ON contain the setting maxOccurs = max. However, the schema does not set minOccurs.
Rendering
The number of occurrences rendered is determined by the value of the object in the input XML before the item. The number of supplied occurrences need not match the value of the object. Note the following rules:
- If the value of the object is greater than the number of occurrences, the Plug-in adds empty elements. If the VALUE clause is specified, the Plug-in initializes the elements accordingly.
- If the value of the object is less than the number of occurrences, the Plug-in does not render the extra occurrences.
- If the value of the object is not in min:max range, the Plug-in throws a SerializationException exception.
Parsing
During parsing, the number of occurrences are determined by the value of the object in the binary data. If the value of the object is not in the min:max range, the Plug-in generates an error.
The Plug-in always trims white spaces before further processing. For example, a PIC X(4) field with the value “ 3” yields three occurrences.
If a field in the OCCURS ... DEPENDING ON clause is a repeating field, the value for determining the actual number of occurrences are the last value processed before the OCCURS ... DEPENDING ON clause.