Posted: Fri Mar 21, 2008 8:23 pm Post subject: TDS or CWF
Knight
Joined: 25 Aug 2006 Posts: 589
I have to model a message which looks like
Header Header_data DataA DataB DataC.....DataA DataB DataC Trailer Trailer_data
There is no space between each field. The space is used here to make it easier to read.
All fileds (like Header Header_data DataA DataB DataC Trailer Trailer_data) are fixed length
DataA DataB DataC can repeat many times. I do not have the number of repeat ahead of time.
For example
HHH12345aaaaaabbbbbbbcccccccc.....* please do not use *...xxxxxxyyyyyyyzzzzzzzzTTT6789
HHH12345 HeaderHeader_data
aaaaaabbbbbbbcccccccc.....* please do not use *...xxxxxxyyyyyyyzzzzzzzz are repaeating DataA DataB abd DataC
TTT6789 TrailerTrailer_data
I like to model this using TDS. But the repeating data between the header and trailer has no tag. Can this be done or I should try using CWF. But I cannot tell the repeat count ahead of time. I am new to this. I just want your advice on which format is better or easier for this type of message.
You'll need TDS, and you will need to use data patterns. Try this:
Code:
Element Header
Local complex type DES='Tagged Fixed Length' Tag='HHH'
HeaderData Length=5
Group Composition='choice' DES='Tagged Delimited' Tag Length=0 maxOccurs='-1'
Group DES='Use Data Pattern'
Element Trailer Data Pattern='TTT.{4}'
Local complex type DES='Tagged Fixed Length' Tag='TTT'
TrailerData Length=5
Element DataABC
Local ComplexType DES='Fixed Length'
DataA Length='?'
DataB Length='?'
DataC Length='?'
The keys to this are:
- You need 'Use Data Pattern' to distinguish between Trailer and DataABC
- You don't want to write a data pattern to describe the whole of DataABC. That's why the choice group has DES='Tagged Delimited', not 'Use Data Pattern'
That second point may need an explanation. When a data pattern matches the bitstream, the matching portion of bitstream is extracted and used in the parsing of the element/group. So it would be no use writing a data pattern such as '[~T]' ( not 'T' ) for DataABC. That would only match a single character, and the subsequent parsing of DataABC would run out of bitstream and fail.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum