|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
  |
|
Handle special characters coming in CDATA tags |
View previous topic :: View next topic |
Author |
Message
|
RudraHubli |
Posted: Tue Apr 12, 2016 2:29 am Post subject: Handle special characters coming in CDATA tags |
|
|
Apprentice
Joined: 18 Oct 2014 Posts: 28
|
All XML messages coming in from 'source system' will include CDATA section for all those tags which may contain any of the special characters.
It is proposed that we will need to introspect such fields which have the value wrapped as CDATA and apply the encoding as mentioned below.
a) The following special characters will not need any conversion, <space> ‘ ( ) + , - . / : @ _
b) We need to convert any other special characters apart from the ones mentioned above into a ‘+’ character.
Any idea How broker recognizes CDATA ?
For some messages we get CDATA and for some message we don't get CDATA then how i will come whether any field is having CDATA or not ?
Please help me..Thanks |
|
Back to top |
|
 |
timber |
Posted: Tue Apr 12, 2016 2:47 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
All XML messages coming in from 'source system' will include CDATA section for all those tags which may contain any of the special characters. |
'Special characters' means different things to different people. Please can you explain
a) why these 'special' characters exist in the input
b) why they need to be wrapped in CDATA
c) why your message flow needs to replace some characters with a '+'.
Quote: |
Any idea How broker recognizes CDATA ? |
Yes, but I'm not saying yet, because I think it's important to check that your analysis and design are correct before we help you to implement your solution. The answer is in the Knowledge Center, if you're desperate to know. |
|
Back to top |
|
 |
RudraHubli |
Posted: Tue Apr 12, 2016 3:23 am Post subject: |
|
|
Apprentice
Joined: 18 Oct 2014 Posts: 28
|
@ timber
I don't know exact reason.. need to check with source system.
We got CR for this.
Now i am mainly looking how to handle it in ESQL..please help |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Apr 12, 2016 4:22 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
RudraHubli wrote: |
@ timber
I don't know exact reason.. need to check with source system.
We got CR for this.
Now i am mainly looking how to handle it in ESQL..please help |
What ESQL code have you written to do this?
Did it work? Did it fail? If it failed, how? What was the error?
What parser would know what a CDATA section is? How does that parser give you information about what type of element in the tree you are looking at? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
RudraHubli |
Posted: Tue Apr 12, 2016 4:35 am Post subject: |
|
|
Apprentice
Joined: 18 Oct 2014 Posts: 28
|
for writing ESQL logic only i am asking below questions ?
How broker identify recognizes CDATA from input message ? based i will put conditions..
and no idea which filed will be having CDATA ? at runtime how i will come to know ? |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 12, 2016 4:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
RudraHubli wrote: |
I don't know exact reason.. need to check with source system.
We got CR for this. |
So you're making a change, but you don't know why? Also what has the source system got to do with this? Surely it's a question of what the destination system (the one consuming the XML) can handle? The source system could send you an XML document with a CDATA section that's a JPG of my cat without issues; the problem's going to come one something tries to parse the data.
RudraHubli wrote: |
Now i am mainly looking how to handle it in ESQL |
Why? At the simplest level, why are these characters a problem? They're valid XML. As my worthy associate points out, "special" characters mean different things to different people - to me, they mean unprintable. Why do they need to be altered, and why isn't the consuming system doing it? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 12, 2016 4:37 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
RudraHubli wrote: |
for writing ESQL logic only i am asking below questions ? |
Why?
RudraHubli wrote: |
How broker identify recognizes CDATA from input message ? based i will put conditions.. |
Why?
RudraHubli wrote: |
and no idea which filed will be having CDATA ? at runtime how i will come to know ? |
Why? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Apr 12, 2016 4:42 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Vitor wrote: |
As my worthy associate points out, "special" characters mean different things to different people - to me, they mean unprintable. |
I find ? to be very special. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
RudraHubli |
Posted: Tue Apr 12, 2016 9:30 pm Post subject: |
|
|
Apprentice
Joined: 18 Oct 2014 Posts: 28
|
I got below reply from designer-
a) why these 'special' characters exist in the input
[<RB>] Field 'Client names' can have special character.
c) why my message flow needs to replace some characters with a '+'. (for any special characters that is not mentioned in the CR)
[<RB>] 'backend system' does not support any special characters other than the ones specified in the CR. So the rule is, if there are any unsupported special characters coming in request, replace it with “+” since this is supported by 'backend system'. |
|
Back to top |
|
 |
RudraHubli |
Posted: Wed Apr 13, 2016 12:35 am Post subject: |
|
|
Apprentice
Joined: 18 Oct 2014 Posts: 28
|
Can i get any help here ? |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Apr 13, 2016 2:08 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
You could start by telling us what tests/experiments you have done yourself.
We really like people to try things for themselves. This way you learn more than by simple folloiwing what a group of stranges on the internet suggest. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Apr 13, 2016 4:14 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
RudraHubli wrote: |
c) why my message flow needs to replace some characters with a '+'. (for any special characters that is not mentioned in the CR)
[<RB>] 'backend system' does not support any special characters other than the ones specified in the CR. So the rule is, if there are any unsupported special characters coming in request, replace it with “+” since this is supported by 'backend system'. |
Ask the architect of the backend system, or of the system you're working with, when two client names are identical after replacing characters with +, then what happens? Particularly how is the correct client name recovered?
And, as mentioned, do your own tests.
Read, Think, Try, Repeat. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
RudraHubli |
Posted: Wed Apr 13, 2016 11:23 pm Post subject: |
|
|
Apprentice
Joined: 18 Oct 2014 Posts: 28
|
I have written below logic but its not generic
SET MSG = CAST( InputRoot.BLOB.BLOB AS CHARACTER CCSID OutputRoot.MQMD.CodedCharSetId);
IF CONTAINS(MSG,'<![CDATA[') THEN
SET MSG2 = SUBSTRING(MSG AFTER '<![CDATA[' );
SET MSG3 = SUBSTRING(MSG2 BEFORE ']]>' );
SET Position1 = POSITION('<![CDATA[' IN MSG) + 9;
SET Position2 = POSITION(']]>' IN MSG);
DECLARE I1 INTEGER 1;
SET len = LENGTH(MSG3);
WHILE I1 <= len DO
SET tchar = SUBSTRING(MSG3 FROM I1 FOR 1);
IF tchar IN ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'0','1','2','3','4','5','6','7','8','9',
' ' , '‘' , '(' , ')' , '+' , ',' , '-' , '.' , '/' , ':', '@' , '_') THEN
SET Schar = Schar || tchar;
ELSE
SET Schar = Schar || '+';
END IF;
SET I1 = I1 + 1;
END WHILE;
END IF;
--SET MSG = REPLACE (MSG , MSG3 , Schar );
SET MSG = OVERLAY(MSG PLACING Schar FROM Position1 FOR len); |
|
Back to top |
|
 |
timber |
Posted: Thu Apr 14, 2016 1:53 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
|
Back to top |
|
 |
Vitor |
Posted: Thu Apr 14, 2016 4:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
timber wrote: |
Finally delete all of the code that you posted, throw it away and never look at it again. It is very, very bad practice to parse XML using ESQL. It is never safe, and you should never do it. |
That ESQL is just horrible. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
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
|
|
|
|