ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportHow to compare two xml values in esql

Post new topicReply to topic
How to compare two xml values in esql View previous topic :: View next topic
Author Message
mqceries
PostPosted: Fri Oct 04, 2013 7:48 am Post subject: How to compare two xml values in esql Reply with quote

Acolyte

Joined: 02 Dec 2011
Posts: 70

HI friends,


Now the requirement wont be as simple as the title. As part of development we have to compare two xml values and next steps follow on this condition. Problem is input xmls were not well formatted and most of the elements have values \t's and \n's at the end. I have been reading those values with LIKE and % at the end. Now i have to read those values into variables and compare them...

<attributeOne>Value
</attributeOne>

while debugging i am seeing the value as Value\t\t\t\t\n (similar to this)

and some elements are properly build

<atrributeTwo>Value</attributeTwo>

now i have to read these into variables and compare them..

please help..

we are using

Code:


MB toolkit Version: 7.0.0.4
Build id: 7.0.0.4-IFix-20120718_1357

Broker : 7.0.0.4



Thanks.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Oct 04, 2013 7:59 am Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6077
Location: Somewhere over the Rainbow this side of Never-never land.

How are you parsing the input stream?

Some options

1) If you are using XMLNSC to create your message tree you could always use the
REPLACE function to remove the offending characters.

2) Read the message as a BLOB and REPLACE the bad text before you parse the BLOB into a message tree.

3) Get the source of the messy XML to clean up their act.

It does occur to me that we need an XML parser with the same functionality that DFDL brings to TDS/CSV data. Here we can try a series of options in the parsing. That would be a more elegant way of doing it.
_________________
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
View user's profile Send private message
Simbu
PostPosted: Fri Oct 04, 2013 8:10 am Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

If I'm correct, you are using XMLNS parser to parse your xml message. Correct me If i'm wrong

Quote:
The XMLNS parser preserves all parts of an XML document, including white space formatting
Back to top
View user's profile Send private message
mqceries
PostPosted: Fri Oct 04, 2013 9:14 am Post subject: Reply with quote

Acolyte

Joined: 02 Dec 2011
Posts: 70

Yes i am using XMLNSC... tried REPLACE function before but not able to get the desired results...

Thanks and appreciate your replies..
Back to top
View user's profile Send private message
dogorsy
PostPosted: Fri Oct 04, 2013 9:31 am Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

Quote:
tried REPLACE function before but not able to get the desired results...


can you please elaborate?... what does your code look like ?, have you looked at a user trace to see why you are not getting the desired results ?
smdavies99 suggestion of reading the message as a BLOB is a good one, remove the offending chars and then parse as XML, have you tried it ?
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Oct 04, 2013 10:13 am Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
1) If you are using XMLNSC to create your message tree you could always use the REPLACE function to remove the offending characters.
Well, you could do that with any domain, including XMLNSC. In fact, the question is not even an XML question really ( except that the OP's actual problem comes from an XML input message ).

The question could be put like this: I have an element in the message tree with a CHARACTER value, but it might contain leading and trailing white space. How do I trim off any leading and trailing whitespace so that I can reliably compare the value with a constant CHARACTER value?

Hopefully that gives you a strong hint about which string function to search for in the info center. If not, feel free to ask.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Oct 04, 2013 10:17 am Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I do not recommend the parse-as-BLOB solution. That might trim away white space that is not 'padding' ( not leading or trailing ). So the value of this tag:
Code:
<value>   one two three   </value>
would become
Code:
onetwothree
when the correct result would be
Code:
one two three

_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Oct 04, 2013 10:20 am Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6077
Location: Somewhere over the Rainbow this side of Never-never land.

kimbert wrote:
I do not recommend the parse-as-BLOB solution. That might trim away white space that is not 'padding'


That's why I suggested option 3) above.

I'd really try to get the input data cleaned up before it hits Broker. The other methods are purely a hack to get round the problem. Not elegant and not nice but sometimes it is the only way.
_________________
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
View user's profile Send private message
mqceries
PostPosted: Fri Oct 04, 2013 10:53 am Post subject: Reply with quote

Acolyte

Joined: 02 Dec 2011
Posts: 70

we have a time constraint and they are not listening to clean up the xml before they send to us..

Did a work around as planned (thought not to entertain them ,but had to).

parsed X'0A' and X'09' new line and horizontal tab parsed then used REPLACE twice and finally TRIM to make sure..

In case if this helps later on..

Code:


DECLARE cNewLine CHAR CAST(X'0A' AS CHARACTER  CCSID InputRoot.Properties.CodedCharSetId ENCODING InputRoot.Properties.Encoding);
      DECLARE tTabChar CHAR CAST(X'09'  AS CHARACTER  CCSID InputRoot.Properties.CodedCharSetId ENCODING InputRoot.Properties.Encoding);

SET EV.PData7=REPLACE(EV.PData,cNewLine,'');
     SET EV.PData8=REPLACE(EV.PData7, tTabChar,'');
SET EV.PData9=TRIM(EV.PData8);

Result:

Pdata  value\n\t\t
           value\t\t
           value
Pdata




SET EV.PData9=TRIM(EV.PData8);
Back to top
View user's profile Send private message
dogorsy
PostPosted: Fri Oct 04, 2013 10:03 pm Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

kimbert wrote:
I do not recommend the parse-as-BLOB solution. That might trim away white space that is not 'padding' ( not leading or trailing ). So the value of this tag:
Code:
<value>   one two three   </value>
would become
Code:
onetwothree
when the correct result would be
Code:
one two three


yes, sorry, I misunderstood the input value, I though the OP meant the character string "Value\t\t\t\t\n" but that means Value followed by special characters.. not very well explained.
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportHow to compare two xml values in esql
Jump to:



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
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.