Author |
Message
|
mverh |
Posted: Thu Sep 16, 2004 9:44 am Post subject: TDS Message modelling question |
|
|
Voyager
Joined: 06 Mar 2002 Posts: 97
|
Env. WBI-MB V5 CSD03
I'm modelling a message that looks like the following:
Record1: HDR1 abcd <== 1 occurence required
Record2: DAT1 abcd 1234 <== 1 occurence required
Record3: DAT2 abcd <== 0 to 4 occurences optional
Record4: DAT3 abcd <== 0 to 1 occurences optional
Record5: END1 abcd <== 1 occurence required
I have CRLF's above for readability but they do not occur in the datastream. So an input message would look something like:
HDR1abcdDAT1abcd1234DAT2abcdDAT2abcdDAT2abcdDAT2abcdDAT3abcdEND1abcd
I have modelled each record as a complex type with the Data Element Separation set to Fixed Length. For example I have a HDR1, DAT1, DAT2, DAT3 and END1 complexTypes with the appropriate elements.
In my message definition I add a local element of each complex type defined in the appropriate order. Each local element in the message definition is configured with the Logical Properties->Local Element min and max occurences set based on the number that may occur. As well, the Physical Properties->TDS1->Local Element Field Id Tag are set accordingly i.e. HDR1, DAT1 etc.
Now this doesn't quite work. If I send in:
HDR1abcdDAT1abcd1234DAT2abcdDAT2abcdDAT2abcdDAT2abcdDAT3abcdEND1abcd
it parses.
However , if I send in:
END1abcdDAT1abcd1234DAT2abcdDAT2abcdDAT3abcdHDR1abcd or HDR1abcd they also parse.
In fact any combination of the records I modelled in any order will parse.
I need to enforce the order and the number of occurences of the records.
Any hint or pointer would be appreciated.
Thanks, Marc |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Sep 16, 2004 10:05 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
This is not a Fixed length message.
This is a TAGGED fixed length message.
You want to create a message that structurally looks like this: Message- Header
- HeaderField1
- ...
- HeaderFieldN
- Body
- End
Make the Header, Body, DAT1, End, etc to be elements of complex types. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mverh |
Posted: Thu Sep 16, 2004 10:10 am Post subject: |
|
|
Voyager
Joined: 06 Mar 2002 Posts: 97
|
Ok, I'll try that option and see how I fare...thanks for the hint... |
|
Back to top |
|
 |
kimbert |
Posted: Fri Sep 17, 2004 1:40 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I need to enforce the order and the number of occurences of the records. |
In that case, you need to do two things:
1. Set the 'Content Validation' property to 'Closed' on all complex types
2. Enable validation in your message flow (probably on the input node ir your case).
When parsing a tagged bitstream, the TDS parser will act like a SAX parser, and simply put into the tree whatever it finds in the bitstream. You need validation enabled if you want to enforce order/cardinality.
Actually, the above steps are a good idea for anyone developing a TDS message model. Validation provides an early warning of any modelling errors. You can always switch it off once the model is correct. |
|
Back to top |
|
 |
mverh |
Posted: Fri Sep 17, 2004 4:03 am Post subject: |
|
|
Voyager
Joined: 06 Mar 2002 Posts: 97
|
Ok, a couple of notes. I checked the complex type that represents my message and it is indeed TAGGED FIXED LENGTH. The complex types that represent each record are FIXED LENGTH.
Also, I don't think I was clear on my description above. Each record HDR1, DAT1, DAT2 etc have multiple fixed length elements. So in my example above for DAT1 abcd is a string element and 1234 is an integer element. Each record has many elements, I wanted to keep my example simple.
SupportPac IA96 has an example (mrm62) that is somewhat similar to my message set and it indicates that I may need to use groups in some manner, perhaps HDR1 being the group identifier, so I am investigating that option.
I also checked Content Validation on the complex types representing my records and message and they are all set to "Closed". Validation on my MQInput node is set to "Content and Value".
Marc |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 17, 2004 4:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Well if your message includes multiple instances of HEADER,BODY,END, then... yeah. You'll need to add at least another outer group.
Or restructure it so that the "Body" and "End" in my example are children of Header, rather than siblings of Header.
And then you need to set the complex type to be a 'SEQUENCE'. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mverh |
Posted: Fri Sep 17, 2004 5:51 am Post subject: |
|
|
Voyager
Joined: 06 Mar 2002 Posts: 97
|
Jeff, looking at my datastream:
HDR1abcdDAT1abcd1234DAT2abcdDAT2abcdDAT2abcdDAT2abcdDAT3abcdEND1abcd
How would you model it? Using IA96 mrm62 as a template I look at it as follows:
- message has a single structure starting with HDR1, the number of occurences of HDR1 is 1
- Each HDR1 has 5 sub-structures 1 that repeats (DAT2)
- the first sub-structure represents the data elements that follow the HDR1 and occur before the first DAT1, is fixed length
- the second sub-structure starts with DAT1 and is fixed length
- the third sub-structure starts with DAT2 is fixed length and repeats 0 to 4 times
- the fourth sub-structure starts with DAT3 is fixed length and is optional
- the fifth (last) substructure starts with END1 is fixed length and occurs once
So this means I need the following:
- a group that represents the HDR1 structure with a group identifier of HDR1
- complex types for each sub-structure that are fixed length
Now here's where I get confused. The complex type that repesents the structures that follow the HDR1 tag can't be fixed length and can't be TAGGED FIXED LENGTH because I have both.
Is it possible to have a group with no identifier? I think I need to step back and rethink this...
Comments appreciated...
Marc |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 17, 2004 5:59 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Okay, so the message will only contain one set of {HDR1,DAT1,DAT2,DAT3,END1}, yes?
Make a complex type that is a sequence that represents HDR1 and contains every field that you say "follow the HDR1 and occur before the first DAT1". This should be fixed length. DO NOT MODEL the HDR1. So, for yoru simple example, the type is HDR1 and it contains one field, a string of length 4 (to hold the abcd).
Do the same for DAT1, DAT2, DAT3, and END1. Each should be a fixed length complex type that includes all fields EXCEPT the field that it "starts with".
Create a complex type, called maybe "BODY" - this should be a tagged fixed length sequence. Add elements of the DAT1, DAT2, and DAT3 complex types. Assign the appropriate information to the tags on these elements ("DAT1",etc.).
Create your message - also a tagged fixed length sequence. Add elements of the HDR1 type, and the END1 type. Add the BODY type AS A TYPE, not an element. Add the appropriate tags to the HDR1 and END1 elements.
This should work, I think. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mverh |
Posted: Fri Sep 17, 2004 6:31 am Post subject: |
|
|
Voyager
Joined: 06 Mar 2002 Posts: 97
|
Quote: |
so the message will only contain one set of {HDR1,DAT1,DAT2,DAT3,END1} |
One set where DAT2 can occur 0 - 4 times and DAT3 0 - 1 times...
Quote: |
Add the appropriate tags to the HDR1 and END1 elements |
Each tag HDR1, DAT1...END1 have multiple elements that follow. In my example I made it look like a single element followed the tag for simplicity sake...I guess I should have been clearer on that point...my apologies...
Marc |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 17, 2004 6:37 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
mverh wrote: |
One set where DAT2 can occur 0 - 4 times and DAT3 0 - 1 times... |
Right.
But not a set like {{HDR1,DAT1,DAT2,DAT3,END1}{HDR1,..etc}}.
mverh wrote: |
Each tag HDR1, DAT1...END1 have multiple elements that follow. In my example I made it look like a single element followed the tag for simplicity sake...I guess I should have been clearer on that point... |
No, I got that.
Quote: |
Make a complex type that is a sequence that represents HDR1 and contains every field that you say "follow the HDR1 and occur before the first DAT1". |
Also, see my original model -"HeaderField1", etc. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mverh |
Posted: Fri Sep 17, 2004 6:51 am Post subject: |
|
|
Voyager
Joined: 06 Mar 2002 Posts: 97
|
Quote: |
Create a complex type, called maybe "BODY" - this should be a tagged fixed length sequence. Add elements of the DAT1, DAT2, and DAT3 complex types. Assign the appropriate information to the tags on these elements ("DAT1",etc.). |
If DAT2 repeats does TAGGED FIXED LENGTH still apply to BODY? |
|
Back to top |
|
 |
mverh |
Posted: Fri Sep 17, 2004 7:01 am Post subject: |
|
|
Voyager
Joined: 06 Mar 2002 Posts: 97
|
Quote: |
Create your message - also a tagged fixed length sequence. Add elements of the HDR1 type, and the END1 type. Add the BODY type AS A TYPE, not an element. Add the appropriate tags to the HDR1 and END1 elements |
How? When I right click the message the context menu only gives me the ability to add elements, group or attributes? |
|
Back to top |
|
 |
kimbert |
Posted: Fri Sep 17, 2004 7:24 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
it indicates that I may need to use groups in some manner |
In v2.1, you could add a compound type within another compound type. In v5.x, the equivalent effect is achieved by adding a group to the complex type. |
|
Back to top |
|
 |
|