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 Index » General IBM MQ Support » MA0T replace, overlay, delete XML-Elements

Post new topic  Reply to topic
 MA0T replace, overlay, delete XML-Elements « View previous topic :: View next topic » 
Author Message
m.schneider
PostPosted: Tue Jul 15, 2008 7:39 am    Post subject: MA0T replace, overlay, delete XML-Elements Reply with quote

Centurion

Joined: 10 Apr 2007
Posts: 132
Location: Germany

I planning to compare xml-messages, ...

load-->Put-->progress-->get-->compare with saved msg

Problem is that they have fields that are unique:

<msg>
<id>12345<id>
<timestam>12.07.08 14:15</timestam>
<a></a>
<b></b>
<c></c>
</msg>

Is there a way to replace, overlay, delete these values?

Thx
Back to top
View user's profile Send private message
sami.stormrage
PostPosted: Tue Jul 15, 2008 7:49 am    Post subject: Reply with quote

Disciple

Joined: 25 Jun 2008
Posts: 186
Location: Bangalore/Singapore

Either I am not getting ur question or this might sound bit technically inacurate to some.. but theres a tool called XML compare to compare two XML messages easily.. is that ur requirement?
_________________
*forgetting everything *
Back to top
View user's profile Send private message Yahoo Messenger
m.schneider
PostPosted: Tue Jul 15, 2008 8:02 am    Post subject: Reply with quote

Centurion

Joined: 10 Apr 2007
Posts: 132
Location: Germany

The problem is that can't compare the progessed msg with the saved one, because each msg has a unique id and timestamp. Therefor I asked if it is possible to manipulate the unique fields.
Back to top
View user's profile Send private message
JosephGramig
PostPosted: Tue Jul 15, 2008 8:11 am    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1244
Location: Gold Coast of Florida, USA

m.schneider wrote:
Is there a way to replace, overlay, delete these values?


Well, the SET statement can be used to "replace, overlay" the values and if you SET the value to NULL, the element in the msg tree will be deleted.

For what it is worth...
Back to top
View user's profile Send private message AIM Address
m.schneider
PostPosted: Tue Jul 15, 2008 8:29 am    Post subject: Reply with quote

Centurion

Joined: 10 Apr 2007
Posts: 132
Location: Germany

Is there a SET in MA0T? Do you have an example?
I didn't find anything in the documentation, ...
Back to top
View user's profile Send private message
JosephGramig
PostPosted: Tue Jul 15, 2008 8:43 am    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1244
Location: Gold Coast of Florida, USA

No, I didn't know you were talking about MA0T.
I have used that tool, but not the way you are trying it...
Back to top
View user's profile Send private message AIM Address
JosephGramig
PostPosted: Tue Jul 15, 2008 9:12 am    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1244
Location: Gold Coast of Florida, USA

now that I stop and think about it, if you know the exact off set and number of bytes you want to overlay, you can overlay those values in the message (actually it will be in the buffer).

There is an overlay command/feature.
Back to top
View user's profile Send private message AIM Address
timjohnarm
PostPosted: Tue Jul 15, 2008 12:54 pm    Post subject: Reply with quote

Apprentice

Joined: 28 Sep 2004
Posts: 40
Location: Melbourne Australia

You need to get V1.2.9 if you don't already have it. It lets you set up your compare files with regular expressions in them. In fact it uses the PCRE(Perl Compatible Regular Expressions) library so your regular expressions can be quite sophisticated.

For the example you have given your compare file would look like

<msg>
<id>12345<id>
<timestam>\d{2}\.\d{2}\.\d{2} \d{2}:\d{2}</timestam>
<a></a>
<b></b>
<c></c>
</msg>

If the <id> also varies then it would become

<msg>
<id>\d{5}<id>
<timestam>\d{2}\.\d{2}\.\d{2} \d{2}:\d{2}</timestam>
<a></a>
<b></b>
<c></c>
</msg>

And if you don't care about validating it as an actual timestamp then

<msg>
<id>12345<id>
<timestam>.{14}</timestam>
<a></a>
<b></b>
<c></c>
</msg>

I have found the best technique for building regular expressions to match really complex messages is to start from a match everything regex and cut and paste from a copy of the message to be matched. In this way if you get it wrong you'll know it was the bit you just added.

Thus working through your example the series of regular expressions might go like this.

^.*

^<msg>
<id>12345<id>
.*

^<msg>
<id>12345<id>
<timestam>.{14}</timestam>
.*

^<msg>
<id>12345<id>
<timestam>.{14}</timestam>
<a></a>
<b></b>
<c></c>
</msg>
$

Note in this example the use of the ^(caret) to anchor the overall regular expression.

Regards
Tim Armstrong
Back to top
View user's profile Send private message
timjohnarm
PostPosted: Tue Jul 15, 2008 1:14 pm    Post subject: Reply with quote

Apprentice

Joined: 28 Sep 2004
Posts: 40
Location: Melbourne Australia

Also to take sami's point a bit further you can invoke any external tool you like using the <System>command.

So in your script you could

<PutFile>
<File>SaveFile.txt</File>
<Dir>c:\SaveDir</Dir>
</PutFile>
<System>
<Command>c:\ProgramFiles\SpecialUtil.exe c:\SaveDir\SavedFile.txt c:\CompareDir>CompareFile.txt</Command>
</System>
<If Cond="%LastCC%.NE.0">
<StdOut>LastCC=%LastCC% LastRC=%LastRC%</StdOut>
-- Do something about it
<ExitTest/>
</If>

This of course assumes that SpecialUtil.exe returns a different ConditionCode depending on success or failure.

Also note that to avoid the test just failing you need and <If...> statement immediately after the MsgTest command that could fail.

Regards
Tim Armstrong
Back to top
View user's profile Send private message
m.schneider
PostPosted: Tue Jul 15, 2008 11:30 pm    Post subject: Reply with quote

Centurion

Joined: 10 Apr 2007
Posts: 132
Location: Germany

Thanks for your reply and examples.

I would prefer to keep it simple. So is there a way to delete the content of the <id> and <timestamp> tags wich can be variable in length. Perhaps get the position of the tags and overlay and delete the content, ...

This would make it easy to compare the msg with a saved msg. Intention of this is to automate regression testing for the message broker.
Back to top
View user's profile Send private message
timjohnarm
PostPosted: Thu Jul 17, 2008 12:29 pm    Post subject: Reply with quote

Apprentice

Joined: 28 Sep 2004
Posts: 40
Location: Melbourne Australia

Yes if you know the fixed position of the string you could overlay with a known value. But then you are going to get a whole lot of <Overlay> commands very quickly. The regular expression file is really the way to go, you capture a sample message put regular expressions in where the timestamps are and away you go, for something with only three or four variable elements it really is quite quick to do.

Here is the set I keep in a clipboard file for cutting and pasting.
\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{6}
\d{4}-\d{2}-\d{2}
\d{2}:\d{2}:\d{2}.\d{3}

Tim
Back to top
View user's profile Send private message
timjohnarm
PostPosted: Sun Jul 27, 2008 3:49 pm    Post subject: Reply with quote

Apprentice

Joined: 28 Sep 2004
Posts: 40
Location: Melbourne Australia

Now that I understand more about PCRE, V1.3.0 is on the way, it includes code to help locate the actual position in the buffer and the regular expression where a mismatch has occured.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » MA0T replace, overlay, delete XML-Elements
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.