Author |
Message
|
jbanoop |
Posted: Tue Dec 12, 2006 4:08 am Post subject: TDS Model fixed length with last element varying length |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
Hi All,
I have a message format of the following format
AAAbbbCCCvvvvvv<LF>
Here AAA,bbb and CCC are fixed length components all having a fixed length of 3 characters but the vvvvvvv can have a variable length ranging from 0 to anything. That would also be the last element before the <LF>.
So some example messages would be..
AAAbbbCCC<LF>
AAAbbbCCCv<LF>
etc..
Any help would be greatly appriciated.
Regards,
Anoop |
|
Back to top |
|
 |
vk |
Posted: Tue Dec 12, 2006 4:41 am Post subject: |
|
|
Partisan
Joined: 20 Sep 2005 Posts: 302 Location: Houston
|
You can define the following components in the message set -
Message_Type (Compound Type) - Data Element Separation = 'Use Data Pattern'
Record (Complex Element) - Data Pattern = '.{100}([^\n]*)\n', minOccurs = 1, maxOccurs = -1
Record_Type - Data Element Separation = 'Variabele Length Elements Delimited', Delimiter = '~' (Give a delimiter which will not be part of the data)
This type should have all the simple elements correcponding to AAA, bbb, CCC and vvvvvvv. Specify a length for all elements except the last one.
Regards,
VK. |
|
Back to top |
|
 |
jbanoop |
Posted: Tue Dec 12, 2006 5:21 am Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
Hi VK,
thanks for the reply. Could you elaborate a bit more ?
By compound type do u mean complex type itself ?
Do yo mean to say
Msg_Type (Use data Pattern)
---- Record - Data Pattern -'.{100}([^\n]*)\n'
---- Record Type 'Variable Length Elements Delimited' delimiter ~
---- Record Type 'Variable Length Elements Delimited' delimiter ~
---- Record Type 'Variable Length Elements Delimited' delimiter ~
I am pretty confused, Would be gr8 if you could guide me a little bit more.
Regards,
Anoop |
|
Back to top |
|
 |
vk |
Posted: Tue Dec 12, 2006 5:40 am Post subject: |
|
|
Partisan
Joined: 20 Sep 2005 Posts: 302 Location: Houston
|
Yes. Compound Type is same as Complex Type (In WMQI 2.1 it was called Compound Type)
Record is an element of type Record_Type. Record_Type will not repeat. Only elements can repeat. So the structure will be as follows -
Message ----- Message_Type (Use Data Pattern)
---------- Record [1] ----------- Record_Type (Variables Length Elements Delimited)
---------- Record [2] ----------- Record_Type (Variables Length Elements Delimited)
---------- Record [3] ----------- Record_Type (Variables Length Elements Delimited)
etc
Also in the data pattern which I mentioned, 100 is the length of the fixed part of the record, excluding the last element whose length can vary.
Regards
VK. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Dec 12, 2006 5:43 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Use <LF> as the delimiter. No reason to use "~" or anything that "won't appear in the message". _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jbanoop |
Posted: Tue Dec 12, 2006 6:06 am Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
Hi Vk,
This is how i have defined the structure
Msg_Type - Use Data Pattern
----- RecElement (type = Rec_Type) minocc=1, MaxOcc=-1 pattern=
'. {11}([^\n]*)\n'
Rec_Type - Variable Elements Delimited
-E1 -size (6)
-E2 - size (5)
-E3 (size is not specified defaulting to 0)
I will test with it and get back, it would be helpful if you could re-confirm that this is actually what you have in mind.
Regards,
Anoop |
|
Back to top |
|
 |
kimbert |
Posted: Tue Dec 12, 2006 2:46 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I try to avoid using Data Patterns - they tend to consume a lot of CPU. I don't think jbanoop's problem requires them.
Try this:
Code: |
MessageType [Data Element Separation=All Elements Delimited, Delimiter='NOTUSED' Group Terminator=<LF>]
LineType [Data Element Separation=VLED (no delimiter required)]
E1 [length=3]
E2 [length=3]
E3 [length=0]
|
LineType and MessageType are the complex types. Your message model will actually contain elements based on these types. |
|
Back to top |
|
 |
jbanoop |
Posted: Tue Dec 12, 2006 9:43 pm Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
Vk,
I think your suggestion works, still not done exhaustive testing though.
Kimbert,
I tried out your suggestion and it works but there is a problem
for inputs such as
aaaBBBcccc<LF>
E1=aaa
E2=BBB
E3=ccc
or
aaaBBB<LF>
E1=aaa
E2=BBB
it works
however for an incorrect single line input like
aaaBB<LF>
(first two fields are mandatory and should be of length 3 each)
instead of throwing a parsing error, it gives
E1='aaa'
E2='BB\n'
My structure is
Msg_Type(AllElemDelimited)-(Delimeter=NOTUSED) group term = <LF>
---Recs (Type=Rec_Type) min occurs = 1 max occurs = -1
Rec_type (VLED) - Delimiter (#-not present in message)
-- E1 - 3
-- E2 - 3
-- E3 - 0
IS there anything I am doing wrong or missing .. any suggestions would be very helpful.
Regards,
Anoop |
|
Back to top |
|
 |
kimbert |
Posted: Wed Dec 13, 2006 3:09 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Hi jbanoop,
- The parser is doing exactly what the model says ( and using a data pattern on the outer complex type would not make any difference ).
- How can the parser know whether the 6th character is supposed to belong to E2 or E3? |
|
Back to top |
|
 |
|