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 » WebSphere Message Broker (ACE) Support » Finding repeated tag duplicate values

Post new topic  Reply to topic
 Finding repeated tag duplicate values « View previous topic :: View next topic » 
Author Message
rsk33
PostPosted: Thu Sep 06, 2012 5:43 am    Post subject: Finding repeated tag duplicate values Reply with quote

Centurion

Joined: 21 Aug 2006
Posts: 141

Hi

I am trying to find out repeated tag duplicate values in a XML request message. I tried with the below code but not successful. Any help is highly appreciated.


DECLARE Ref REFERENCE TO InputRoot.XMLNSC.TEST[1]
WHILE LASTMOVE(inRef) = TRUE DO

IF(SELECT count(*) FROM InputRoot.XMLNSC.TEST.Id[] AS F where F = Ref.Id) > 1 THEN
-- IF CARDINALITY(SELECT F.* FROM InputRoot.XMLNSC.TEST.Id[] AS F where F = Ref.Id ) > 1 THEN


SET Environment.variables.Duplicate = Ref.Id ;

END IF;

MOVE inRef NEXTSIBLING REPEAT TYPE NAME;

END WHILE;

input message is
<?xml version="1.0" encoding="UTF-8"?>
<Test>
<Id>1</Id>
</Test>
<Test>
<Id>1</Id>
</Test>
<Test>
<Id>2</Id>
</Test>

Regards
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Sep 06, 2012 5:50 am    Post subject: Re: Finding repeated tag duplicate values Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

rsk33 wrote:
I tried with the below code but not successful.

What was the result?

Why was the result 'unsuccessful'?
Back to top
View user's profile Send private message
rsk33
PostPosted: Thu Sep 06, 2012 5:55 am    Post subject: Reply with quote

Centurion

Joined: 21 Aug 2006
Posts: 141

i debug and checked that the if condition is failing and moving to next sibling and the Environment.variables.Duplicate = Ref.Id is never set.
Back to top
View user's profile Send private message
rsk33
PostPosted: Thu Sep 06, 2012 6:03 am    Post subject: Reply with quote

Centurion

Joined: 21 Aug 2006
Posts: 141

Hi jeff,

Thanks for the response. Am i missing something or any alternate code that can work.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Sep 06, 2012 6:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

rsk33 wrote:
Hi jeff,

Thanks for the response. Am i missing something or any alternate code that can work.


Well, your second attempt at the select is not strictly correct.

Code:
SELECT count(*) FROM InputRoot.XMLNSC.TEST.Id[] AS F where F = Ref.Id

should be
Code:
SELECT count(F.*) FROM InputRoot.XMLNSC.TEST.Id[] AS F where F = Ref.Id


And, in general, when I'm having trouble getting a condition statement to work, I rewrite it so I can observe both sides of the condition before the evaluation of the condition. So I'd put the select statement into a separate line and store the result into a local variable. then check if the local variable is > 1.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Sep 06, 2012 6:18 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

rsk33 wrote:
Am i missing something


That your SELECT is wrong

rsk33 wrote:
any alternate code that can work.


Well a correctly coded SELECT that returns a result would be a help.

Am I correct is saying you're trying to detect if an Id tag has the same value rather than the existance of multiple Id tags? If so you'd be looking for something like:

Code:
IF CARDINALITY(SELECT F.Id FROM InputRoot.XMLNSC.Test[] AS F WHERE FIELDVALUE(F.Id) = FIELDVALUE(Ref.Id)) > 1


This code is untried, untested, would require some modifications to your loop and is provided for illustrative purposes only.

Better solutions are undoubtably possible and someone may post one.

I'd also repeat the advice to use a user trace rather than the debugger. That's showing you the condition is failing; the user trace will show you why it's failing.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
rsk33
PostPosted: Thu Sep 06, 2012 6:42 am    Post subject: Reply with quote

Centurion

Joined: 21 Aug 2006
Posts: 141

Hi Jeff/victor

I tested both changes but the suggested cardinality is working.
Thanks a lot and also for the wonderful forum experts.

Regards
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 » WebSphere Message Broker (ACE) Support » Finding repeated tag duplicate values
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.