Message Sets: Using multiple delimiters

To parse messages in which fields are delimited by one of a set of characters or strings, set Data Element Separation to the method Use Data Pattern.

For example, consider a simple message with two numeric fields that can have either of the characters ';' or '/' delimiting them. You can use two approaches:

  • Model the delimiter as a data element which is added to the message tree. If the message is rewritten, it looks like the input message.
    Consider this model:
    Composition = Sequence
    Data Element Separation = Use Data Pattern
    			FieldA    Data Pattern = [0-9]* 
    			Delim     Data Pattern = [;/] optionally with a default value.
    			FieldB    Data Pattern = [0-9]*

    After parsing, the elements FieldA and FieldB each contain any number of the digits 0 - 9, and the element Delim contains either ";" or "/".

  • Recognize the delimiter as a delimiter, which is not added to the tree. If the message is rewritten, a preferred delimiter (as specified in the model) is used.
    Consider this model:
    Composition = Choice
    Data Element Separation = Use Data Pattern
    		SubType1	Data Pattern = [0-9]*;[0-9]*
    		(Composition = Sequence
    		Data Element Separation = All Elements Delimited
    		Delimiter = ';')
    			FieldA
    			FieldB
    		SubType2	Data Pattern = [0-9]*/[0-9]*
    		(Composition = Sequence
    		Data Element Separation = All Elements Delimited
    		Delimiter = '/')
    			FieldA
    			FieldB

    The regular expressions differentiate between the two options that can occur in the message, which are then parsed as a normal delimited structure. After parsing, the elements FieldA and FieldB each contain any number of the digits 0 to 9. The delimiter found in the input message is not saved in an element.

    You could refine this approach by using different names for the children, or elements for SubType1 and SubType2, to provide the knowledge of which delimiter is used, or to control which delimiter is included in the output message.