Using multiple delimiters

If you set Data Element Separation to the method Use Data Pattern, messages in which fields are delimited by one of a set of characters or strings can be parsed.

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

  1. 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 to 9, and the element Delim contains either ";" or "/".

  2. 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.

Related concepts
Message modeling
The message model
TDS format: Relationship to the logical model
Related tasks
Developing message models
Working with a message definition file
Working with message model objects
Related reference
Message model reference information
Message model object properties
Additional MRM domain information
Additional TDS information