Author |
Message
|
eskil |
Posted: Tue Nov 25, 2008 4:44 am Post subject: Defining a TDS format i WMB that has "variable" le |
|
|
Novice
Joined: 25 Nov 2008 Posts: 14
|
Hi.
I have an incoming message in TDS format that I want to convert to XML. The problem I'm having is that the message can be sent in two formats. The latter is an extended version (i.e has some additional fields) of the "original" one.
My approach was to create a message definition for all the common fields (min/max occurs = 1/1) for the two versions, and then add a sequence (min/max occurs = 0/1) at the end where the rest of the fields (min/max occurs = 1/1) are added.
I've tried to visualize it below:
Code: |
commonfield1 (min/max occurs = 1/1)
commonfield2 (min/max occurs = 1/1)
commonfield3 (min/max occurs = 1/1)
sequence (min/max occurs = 0/1)
--extrafield1 (min/max occurs = 1/1)
--extrafield2 (min/max occurs = 1/1) |
Doing this I managed to parse messages of the extended version, but not of the original (subset) version. Is this even doable, or do I have to solve this with code inside my flow? (I.e get the message as a BLOB and then parse the message to the specific format based on the message length) |
|
Back to top |
|
 |
kimbert |
Posted: Tue Nov 25, 2008 6:01 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
The problem I'm having is that the message can be sent in two formats. The latter is an extended version (i.e has some additional fields) of the "original" one. |
Please provide at least one example of each input format. The answers to your questions depend on that information. |
|
Back to top |
|
 |
eskil |
Posted: Tue Nov 25, 2008 7:12 am Post subject: |
|
|
Novice
Joined: 25 Nov 2008 Posts: 14
|
Hi.
Clarification: The input data is in a fixed length format.
Example:
Original: AAABBBCCC
Extended: AAABBBCCCDDEEFF
Field: "AAABBBCCC" is the common part, that exists in both versions.
Field: "DDEEFF" is considered as the "extended" part and these fields will always exist together. Basically the message only have two different lengths.
/Emil |
|
Back to top |
|
 |
kimbert |
Posted: Tue Nov 25, 2008 8:22 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Doing this I managed to parse messages of the extended version, but not of the original (subset) version |
I expect you were told that the bitstream was too short. In a fixed-length message, optional fields ( minOccurs=0) are treated as though they are mandatory ( minOccurs=1).
You have two solutions available:
a) Set the input domain to BLOB. In a Compute node, test the length of InputRoot.BLOB.BLOB, and then reparse using either CREATE...PARSE or RCD nodes
b) Use data patterns to distinguish between the two message types.
The message structure would have to be something like this:
Code: |
Message Composition='Choice' DataElementSeparation='Use Data Pattern'
Group DataElementSeparation='Fixed Length' Data Pattern='.*[15]'
elementAAA
elementBBB
elementCCC
elementDDD
elementEEE
elementFFF
Group DataElementSeparation='Fixed Length' Data Pattern='.*[9]'
elementAAA
elementBBB
elementCCC
|
Note that the longer group must come first in the choice, otherwise the shorter one will match first. |
|
Back to top |
|
 |
eskil |
Posted: Wed Nov 26, 2008 2:10 am Post subject: |
|
|
Novice
Joined: 25 Nov 2008 Posts: 14
|
I eventually got it to work. I had to use date patterns with curly brackets instead of square brackets.
Code: |
Message Composition='Choice' DataElementSeparation='Use Data Pattern'
Group DataElementSeparation='Fixed Length' Data Pattern='.{15}'
elementAAA
elementBBB
elementCCC
elementDDD
elementEEE
elementFFF
Group DataElementSeparation='Fixed Length' Data Pattern='.{9}'
elementAAA
elementBBB
elementCCC
|
Thank you for your help! |
|
Back to top |
|
 |
|