Author |
Message
|
messg_wb |
Posted: Wed May 10, 2006 7:09 pm Post subject: TDS msg parsing for null values |
|
|
Acolyte
Joined: 29 Sep 2005 Posts: 51
|
Hi,
I am trying to parse a 'variable length delimited element' message. Delimited char is ';' and message consists of some null value elements and position of the element is important. My message set has a single element. The problem is, when I it encounters empty element (or) two succesive delimiters it doesn't store 'null' value in element so I am loosing the position.
I tried to fix it by changing logical properties of element as 'Nillable' and having 'Encoding Null' as 'NullLiteralValue' and 'Encoding Null Value' as 'null'. (I am working on Message broker 6.0)
Am I missing something here ? Thanks for your help. |
|
Back to top |
|
 |
kimbert |
Posted: Thu May 11, 2006 12:17 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Almost right. Encoding Null Value describes the physical representation of the null ( i.e. what a null looks like in the input or output bitstream) , so in your case you should set it to "" ( empty string ). |
|
Back to top |
|
 |
Mensch |
Posted: Thu May 11, 2006 3:29 am Post subject: |
|
|
Disciple
Joined: 17 Jul 2005 Posts: 166
|
|
Back to top |
|
 |
elvis_gn |
Posted: Thu May 11, 2006 4:26 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi Mensch,
I don't think this problem is worth using data patterns...
I feel kimbert's solution is simpler and better for performance.
Regards. |
|
Back to top |
|
 |
messg_wb |
Posted: Thu May 11, 2006 6:39 am Post subject: |
|
|
Acolyte
Joined: 29 Sep 2005 Posts: 51
|
Kimbert,
I tried using empty string "" but the result is same. I am still not able to see the empty elements in message debugger. I have checked Nillable property and kept "Interpret Value as " as NONE, Is that right ?
Thanks,
Mohan |
|
Back to top |
|
 |
kimbert |
Posted: Thu May 11, 2006 7:40 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Hi messg,
- Are you sure your message is 'variable length elements delimited'. Most people pick that option when they really should have used 'All Elements Delimited'. Unless you have non-delimited fixed-length elements mixed in with your variable-length elements, you should change to 'All Elements Delimited'.
- Don't worry about 'Interpret Element Value As' - it has no effect on null handling. Your other null handling settings are correct.
- I think I need to know a bit more about your input message, your message model and your desired message tree. Please post an example of the input message. I'm particularly puzzled by this statement in your original post:
Quote: |
My message set has a single element |
Are you saying that your input message consists of one element which repeats? |
|
Back to top |
|
 |
messg_wb |
Posted: Thu May 11, 2006 8:28 am Post subject: |
|
|
Acolyte
Joined: 29 Sep 2005 Posts: 51
|
Hi Kimbert,
I specified as "All Elements delimited" (Initially, I did same mistake by taking as variable length elements delimited but as I was researching this problem I changed it to 'All Elements delimited')
My message is similar to:
Elem1;Elem2;Elem3;;;Elem6
Due to some constraints, I cannot define multiple elements in the message set so I defined single element as 'Elm' and am trying to create msg as
Elm[1] = Elem1
Elem[2] = Elem2
Elem[3] = Elem3
Elem[4] = null
Elem[5]=null
Elem[6]=Elem6
But when I send above sample message, it is taken as
Elm[1] = Elem1
Elem[2] = Elem2
Elem[3] = Elem3
Elem[4] = Elem6
Thanks,
Mohan |
|
Back to top |
|
 |
kimbert |
Posted: Fri May 12, 2006 12:55 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Due to some constraints, I cannot define multiple elements in the message set |
This is causing you a real problem. What are the constraints?
Here are the rules:
1. When parsing All Elements Delimited data, the TDS parser never writes empty elements to the tree.
2. When parsing a repeating element, if two consecutive delimiters are encountered, the repeats are terminated.
That first rule is the one which is causing your problems. You now have two choices:
a) Model your sequence as Elem1, Elem2, Elem3, Elem4, Elem5, Elem6.
You will find that Elem4 and Elem5 will not appear in the tree, but that will not matter, because you will have distinct names for the elements.
b) Set Data Element Separation to 'Use Data Pattern'. If you want to take this option, post again and I'll walk you through the modeling. |
|
Back to top |
|
 |
messg_wb |
Posted: Fri May 12, 2006 1:05 pm Post subject: |
|
|
Acolyte
Joined: 29 Sep 2005 Posts: 51
|
Thanks for your reply Kimbert.
Let me explain clearly the complete scenario. Message consists of multiple records and each record has multiple elements and delimiting factor, "," (for records and elements). Also element can consist of ',' with quotes, for instance "Kim,bert", so when parsing it would take 'Kim' as 1 element and 'bert' as another element. Also, some of the elements can be null.
I thought about Data patterns but data consists of some special chars, also we do not know which element has quotes("") so, I wasn't sure if I would be able to do it.
Currently, I am parsing manually, reading each char into a element and combining chars to form elements and combinig elements to form records, I know its the most crude way..
Let me know, if you see any easy way.
Rgds,
Mohan |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 15, 2006 12:44 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Let me explain clearly the complete scenario |
Good idea. It's difficult to give advice without knowing the facts
Quote: |
thought about Data patterns but data consists of some special chars |
The CSV sample clearly shows that Data Patterns are the solution to this problem.
Quote: |
Currently, I am parsing manually, reading each char into a element and combining chars to form elements and combinig elements to form records, I know its the most crude way.. |
Yes it is. And it will be a maintenance nightmare. I strongly suggest that you take a close look at the CSV samples ( particularly Sample Message CSV_7
) and implement a solution based on a message set. |
|
Back to top |
|
 |
|