Specifying Optional Fields and Records

About this task

When creating optional fields or records in a Flat File Schema, it is important to understand how the Flat File data is parsed so you can design your Flat File schema to avoid ambiguity. For example, if you create a Flat File Schema with a delimited root node and three child string fields where field1 is required, field2 is optional, and field3 is required, the grammar of the schema is ambiguous, as shown when the following data is parsed during run time:

A,C

This Flat File data could be parsed in the following two ways:
  • field1 is equal to A and field2 is equal to B
  • field1 is equal to A and field3 is equal to C

Specifying a required field after an optional field defines an ambiguous grammar that cannot be correctly parsed. Specifying a required record after an optional field also defines an ambiguous grammar that cannot be correctly parsed.

Redefining this Flat File Schema to contain three child string fields where field1 is required, field2 is optional, and field3 is optional does not fix this problem because when the Flat File data: A,C is parsed, field1 is equal to A, and field2 is equal to C. Again the grammar of the schema is ambiguous because this is not the wanted result, the wanted result was for the value: C to be assigned to field3. Specifying a required record followed by two optional records also defines an ambiguous grammar.




Feedback | Notices


Timestamp icon Last updated: Wednesday, 15 June 2016


http://pic.dhe.ibm.com/infocenter/wci/v7r0m0/topic/com.ibm.wci.doc/Specifying_Optional_Fields_and_Records.html