Author |
Message
|
6thelement |
Posted: Mon Jul 05, 2010 1:54 am Post subject: Tagged Delimited Problem |
|
|
Apprentice
Joined: 07 Nov 2008 Posts: 30
|
Hi All,
I am trying to create a message set for a flat file which looks like the following.
00023apple*truck*banana
00035car*orange*bus
00042tiger*road*rabbit
On each record, the first element is integer with length 5(fixed). After that, rest of the elements variable length delimited with delimiter between elements as * and record separator as <CR><LF>.
I tried modeling this using Data Element Separation:Tagged Delimited,
* Created two complex types.
ComplexType1:
Data Element Separation:Tagged Delimited
Delimiter:<CR><LF>
Length Of the Tag:5
ComplexType2:
Data Element Separation:All Elements Delimited
Delimiter:*
* Added three local elements under ComplexType2 to model the output.
EL1 of string type
EL2 of string type
EL3 of string type
* Made the Message of type ComplexType1 and created a local element "CTElement" under it of type ComplexType2 (Child of ComplexType1). Also made the repeating element delimiter of "CTElement" as <CR><LF>.
The first element(fixed length of 5) is not required in the output.
Now when I run the flow and trying to parse a message as shown above, I am getting the following tree in the Debugger.
CTElement
EL1: 00023
EL2: apple
EL3: truck*banana\r\n00035car*orange*bus\r\n00042tiger*road*rabbit
Whereas I am expecting this:
CTElement:
EL1:apple
EL2:truck
EL3:banana
CTElement:
EL1:car
EL2:orange
EL3:bus
CTElement:
EL1:tiger
EL2:road
EL3:rabbit
Please let me know where I am going wrong. I am using WMB V6.1.
Thanks,
Sam |
|
Back to top |
|
 |
kimbert |
Posted: Mon Jul 05, 2010 4:10 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Tip: please can you use [code] tags when posting complex descriptions - it makes the text much easier to read.
You're almost there. I think you need to set maxOccurs on CTElement to 'unbounded' and set the Repeating Element Delimiter to <CR><LF>. It is a good idea to set the Group Terminator to <CR><LF> as well, in case you get a trailing <CR><LF> in the input message. |
|
Back to top |
|
 |
6thelement |
Posted: Mon Jul 05, 2010 4:27 am Post subject: |
|
|
Apprentice
Joined: 07 Nov 2008 Posts: 30
|
Hey Kimbert,
Good to see your reply. I will be posting the exact message set from toolkit tomorrow. I have kept the CTElement maxOccurs to unBounded and also have kept a group terminator as well as repeating element delimiter as <CR><LF>. Still wondering why I am facing the problem. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Jul 05, 2010 4:39 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Looks as if you forgot to set the 'Tag' property on the child elements. |
|
Back to top |
|
 |
6thelement |
Posted: Mon Jul 05, 2010 5:10 am Post subject: |
|
|
Apprentice
Joined: 07 Nov 2008 Posts: 30
|
When you say child elements, are you talking about EL1, EL2 etc? If Yes, they are all elements delimited and so we may not need to set tag property for them. Sorry if I didnt understand your suggestion. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jul 05, 2010 5:52 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I'm confused.
There are no tags in this data that I can see. The value for the CTElement appears to be extremely variable, being either "00023" or "00035" or "00042".
If you want the model to consume that piece of data, and not make it visible in the logical tree, then it has to be a tag.
But tags have to have a *constant* value. So you need three instances of elements of ComplextType2, each with a different tag value.
If you need to do some logic using this value "00023" or etc, then you can't define it as being a tag.
And if this value is not actually a choice of the three values you've given, i.e. it can be any five-digit integer and has no relationship to the contents of the child elements, then you need to rework your model entirely. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Jul 05, 2010 5:56 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
In your current model you have set Tag Length to 5, but have not set the Tag property on CTElement. You need to decide how you want to model those first 5 characters. Either they are redundant ( so use Variable Length Elements Delimited, and add a field with name 'tag' and length=5 as the first child of CTElement ) or else they are conveying important information about the fields that follow ( so you need to define CTElement1, CTElement2, CTElement3 and set their Tag property to '00023', '00035','00042' ) |
|
Back to top |
|
 |
6thelement |
Posted: Mon Jul 05, 2010 6:06 am Post subject: |
|
|
Apprentice
Joined: 07 Nov 2008 Posts: 30
|
Hi Jeff,
The reason I went for Tagged Delimited is
-> There is a combination of one fixed length length element and multiple delimited elements in the input record.
-> And there is no delimiter between between these two different type of elements.
Which means I can not model ComplexType1 as All Elements delimited. So I thought Tagged Delimited will be ideal for this. I dont mind getting the value "00023" in the logical message tree as I am not mapping it to output anyway.
Quote: |
And if this value is not actually a choice of the three values you've given, i.e. it can be any five-digit integer and has no relationship to the contents of the child elements, then you need to rework your model entirely.
|
You are right. thats how it is.
If not Tagged Delimited, how do I model this fixed length element and variable elements delimited combination.
Thanks.... |
|
Back to top |
|
 |
6thelement |
Posted: Mon Jul 05, 2010 6:30 am Post subject: |
|
|
Apprentice
Joined: 07 Nov 2008 Posts: 30
|
@Kimbert
Taking the first option as below:
Quote: |
Either they are redundant ( so use Variable Length Elements Delimited, and add a field with name 'tag' and length=5 as the first child of CTElement )
|
If I understood it correctly, this is what I will do other than the steps I ahve done already..
I will add a field named "Tag" with length "5" as the first element of CTElement making it Variable Length Elements Delimited. As I have defined ComplexType1 as Tagged Delimited, so I guess this "Tag" field will not come in the message tree. Also there wont be any delimiter between "Tag" and rest of the field that follows even if CTElement is defined as Variable Length Elements Delimited.
Please let me know if this is what you suggested.
Thanks.. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Jul 05, 2010 10:38 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I will add a field named "Tag" with length "5" as the first element of CTElement making it Variable Length Elements Delimited. |
I just want to make sure I understand that. You will
a) Change the Data Element Separation property on the outermost complex type to 'Variable Length Elements Delimited'.
b) Add the new child element 'tag' and set its length to '5'.
You have to do both - a) will not happen automatically, as your wording seemed to imply.
Quote: |
As I have defined ComplexType1 as Tagged Delimited, so I guess this "Tag" field will not come in the message tree. |
Not true. You need to change it from Tagged Delimited to VLED.
Quote: |
Also there wont be any delimiter between "Tag" and rest of the field that follows even if CTElement is defined as Variable Length Elements Delimited. |
Correct. This is what VLED is for. If length=0 then a delimiter is expected. If length>0 then no delimiter is required or expected. |
|
Back to top |
|
 |
6thelement |
Posted: Tue Jul 06, 2010 10:30 am Post subject: |
|
|
Apprentice
Joined: 07 Nov 2008 Posts: 30
|
Hi Kimbert...
Thanks..You people are of really help. I think I was thinking too complicated without getting into the basics.It exactly worked in the same way you have mentioned.
Here is what I did.
* Created two complex types.
ComplexType1:
Data Element Separation:All Elements Delimited
Delimiter:<CR><LF>
ComplexType2:
Data Element Separation:Variable Length Elements Delimited
Delimiter:*
* Added four local elements under ComplexType2 to model the output.
Tag of string type with Length 5
EL1 of string type with Length 0
EL2 of string type with Length 0
EL3 of string type with Length 5
* Made the Message of type ComplexType1 and created a local element "CTElement" under it of type ComplexType2 (Child of ComplexType1). Also made the repeating element delimiter of "CTElement" as <CR><LF> and Group Terminator:<CR><LF>
Thanks to Jeff too.
Sam.. |
|
Back to top |
|
 |
|