Sequences and choices

Within an FSD, you can define either fixed sequences of records, or an arbitrary order of records.

Fixed sequence is where each record defined in the sequence must be in the order specified. This is the most common construct in FSD since most flat data structures are designed to receive the data in a specified order.

A flat data format is where records and fields are specified in an arbitrary order, or where markers in the data determine the structure of the records. You can use the 'choice' element for these data structures. Pattern matching is run by this element to determine the best record to use to generate output. The pattern match compares field lengths, the delimiters for a field, the number of fields and any specified valid value for the field.

Note: The 'choice' element impacts the performance of data processing so we recommend that it is used as a last resort.

Number of occurrences

The expected number of occurrences are specified using the sequence, choice and record elements in the FSD. The data is validated by the FSD processor using this information.

The 'max-occurs' attribute is set to 1 by default. This means that only one occurrence of the given record, sequence or choice is expected to occur. For some types of flat data this may be another fixed number, although in many cases, any number of occurrences are valid. This is specified using the value 0 which determines that the records are processed by the FSD until a non-matching record is found.

The 'min-occurs' attribute is only used for validation and for pattern matching with the 'choice' element. Before moving to the next record, a check is run by the FSD processor on the number of occurrences against the minimum number specified by 'min-occurs'. This generates an error if too few occurrences are found.