|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
TDS messageset |
« View previous topic :: View next topic » |
Author |
Message
|
mqbrk_newbie |
Posted: Tue May 10, 2005 1:58 pm Post subject: TDS messageset |
|
|
 Acolyte
Joined: 13 Sep 2004 Posts: 70
|
I have an incoming data that looks like this
4233001 01 12355 Abcd 12345 <CR><LF>
3244566 02 232 232 Hdd 345576 abcd <CR><LF>
3244566 02 232 232 Hdd 345576 abcd <CR><LF>
3454554 03 45645 BGGB 234 <CR><LF>
4233001 01 12355 Abcd 12345 <CR><LF>
3244566 02 232 232 Hdd 345576 abcd <CR><LF>
3244566 02 232 232 Hdd 345576 abcd <CR><LF>
There are no spaces between each elements. I just put that for better understanding. If you look at these record, each record ends with a carriage return line feed and has fixed number of bytes. These record has 'TYPE' on the 8th and 9th byte, which can be of numbers (01-05), each has got their own set of fixed format of elements . These types can occur multiple times in any order. I thought of using the Tagged fixed length separation types using these 'TYPES'(01- 05) as the tag name, but I have these 7 bytes of numbers in the front. These types doesnt comes at the start of the record.
Could any one give an idea of how to parse these record using TDS. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue May 10, 2005 3:47 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Well, you could certainly do this as a Data Pattern, matching the first stuff as a blob until you get to 01, 02, or etc.
But is there a reason you made the first 7 bytes the same for each occurance of 01, and the same for each of 02, and etc.?
If there is, that can probably be used as a tag. Or you could model the first bit as a fixed length field and then have a complex choice type that is identified by tag to follow. I mean, it's not like the 7 characters are going to change size or definition, are they?
Something like - Msg(Variable Elements Delimited)
- FirstField
- ChoiceGroup(tagged Fixed Length)
- Record1Type
- Record2Type
- Record3Type
- ...
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mqbrk_newbie |
Posted: Sat May 14, 2005 1:12 pm Post subject: TDS messageset |
|
|
 Acolyte
Joined: 13 Sep 2004 Posts: 70
|
Thanks a lot of Jeff,
I tried your method and it worked out for me.
I could able to parse the message now. I am trying to convert this into an XML format. For example if I am converting this message into XML format,
4233001 01 12355 Abcd 12345 <CR><LF>
3244566 02 232 232 Hdd 345576 abcd <CR><LF>
3244566 02 232 232 Hdd 345576 abcd <CR><LF>
3454554 03 45645 BGGB 234 <CR><LF>
4233001 01 12355 Abcd 12345 <CR><LF>
3244566 02 232 232 Hdd 345576 abcd <CR><LF>
3244566 02 232 232 Hdd 345576 abcd <CR><LF>
I get the output like this
<xml>
<message>
<Type01>
<field1>4233001</field1>
<field2> Abcd</field3>
<field3> 12345</field4>
<Type01>
<Type01>
<field1>12355</field1>
<field2>Abcd </field2>
<field3> 12345</field3>
<Type01>
<Type02>
<field1>232</field1>
<field2>232 </field2>
<field3> hdd</field3>
<Type02>
<Type02>
<field1>232</field1>
<field2>232 </field2>
<field3> hdd</field3>
<Type02>
<Type03>
<field1>232</field1>
<field2>232 </field2>
<field3> hdd</field3>
<Type03>
</message>
</xml>
If you observe my xml output I am not getting the exact sequence of type that i am sending as an input.
My i/p sequence is 01,02,02,03,01,02,02,
My o/p sequence 01,01,01,02,02,03
Is there anyway that I could rearrange the sequence in XML as it is in Input or this is the default XML property.
Thanks a lot in advance... |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat May 14, 2005 4:40 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
This to me looks very much like the make up of SAP IDOCs.
Change your xml so that the types are in a hierarchy.
That is if you can't have a type 2 unless there is a type 1 then the hierarchy should look like
<type 1>
<type 2>......</type 2>
<type 2>
...........
<type 3>....</type 3>
</type 2>
</type 1>
<type 1>...</type 1>
Enjoy
 |
|
Back to top |
|
 |
mqbrk_newbie |
Posted: Sat May 14, 2005 7:18 pm Post subject: TDS messageset |
|
|
 Acolyte
Joined: 13 Sep 2004 Posts: 70
|
Thanks a lot..
But I still cannot understand what you said. Can you please elaborate on this..How can I bring this in a hierarachial manner . I can have my input in any sequence . How can I get that in the same sequence..
Thanks a lot in advance.. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun May 15, 2005 8:14 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The order of fields in the output root is almost always controlled by the order of the ESQL statements that create them. So if the order is changing, it is because you are processing type 1 records and then processing type 2 records, and etc.
Yes, there are other ways to fix this - but they only apply in certain specific cases and you probably aren't using them - since it's not likely you're modelling your XML as a CWF structure!
So change the order of your code so that it processes records as they occur, or so that it produces them in the right order. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mqbrk_newbie |
Posted: Mon May 16, 2005 3:56 pm Post subject: TDS messageset |
|
|
 Acolyte
Joined: 13 Sep 2004 Posts: 70
|
jeff ,
I tried to do it by changing the order in my code . Its not working out for me. For example If I get an Input order like this
01, 02,01,01,02,03
MY out output in xml should look like this
<xml>
<01></01>
<02></02>
<01></01>
<01></01>
<02></02>
<03></03>
Whenever I try to code it , my output always looks like this,
<01></01>
<01></01>
<01></01>
<02></02>
<02></02>
<03></03>
Like all 01's together all 02's together....
If possible can you please give me some example of how do i rearrange xml ouput in order of input..
thanks a lot |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|