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 » Combine two XML incoming repeatable tags into one

Post new topic  Reply to topic
 Combine two XML incoming repeatable tags into one « View previous topic :: View next topic » 
Author Message
klabran
PostPosted: Wed Apr 28, 2004 1:15 pm    Post subject: Combine two XML incoming repeatable tags into one Reply with quote

Master

Joined: 19 Feb 2004
Posts: 259
Location: Flagstaff AZ

I have an incoming XML record like...

<PersonPhysicalFeature>
<PersonPhysicalFeature_ROW>
<PhysicalFeatureCategoryText>TATT</PhysicalFeatureCategoryText>
<PhysicalFeatureLocationText>UPP CHES</PhysicalFeatureLocationText>
<PhysicalFeatureDescriptionText>&quot;USMC&quot;</PhysicalFeatureDescriptionText>
</PersonPhysicalFeature_ROW>
</PersonPhysicalFeature>
<OtherPersonPhysicalCharacter>
<OtherPersonPhysicalCharacter_ROW>
<PhysicalFeatureCategoryText>FACIAL HAIR</PhysicalFeatureCategoryText>
<PhysicalFeatureLocationText>FACE</PhysicalFeatureLocationText>
<PhysicalFeatureDescriptionText>BEARD</PhysicalFeatureDescriptionText>
</OtherPersonPhysicalCharacter_ROW>
</OtherPersonPhysicalCharacter>

I need it to end up like....

<PersonPhysicalFeature>
BLAH.....
</PersonPhysicalFeature>
<PersonPhysicalFeature>
BLAH.....
</PersonPhysicalFeature>

SET OutputRoot.XML.Arrest.ActivitySuspect.PersonPhysicalDetails.PersonPhysicalFeature[]=(SELECT R.PhysicalFeatureCategoryText,R.PhysicalFeatureLocationText,R.PhysicalFeatureDescriptionText FROM InputBody.Arrests.Arrest[I].PersonPhysicalFeature.PersonPhysicalFeature_ROW[] AS R);

SET OutputRoot.XML.Arrest.ActivitySuspect.PersonPhysicalDetails.PersonPhysicalFeature[]=(SELECT R.PhysicalFeatureCategoryText,R.PhysicalFeatureLocationText,R.PhysicalFeatureDescriptionText FROM InputBody.Arrests.Arrest[I].OtherPersonPhysicalCharacter.OtherPersonPhysicalCharacter_ROW[] AS R);

Problem with above code is that the second set would overwrite the first set right? ESQL doesn't support UNIONS so what are my alternatives for this?
Back to top
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Wed Apr 28, 2004 1:23 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Detach and attach the proper tree.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
klabran
PostPosted: Wed Apr 28, 2004 2:22 pm    Post subject: Reply with quote

Master

Joined: 19 Feb 2004
Posts: 259
Location: Flagstaff AZ

How would I get around dropping the *_ROW from each Other Character row using detach and attach?

I was thinking something like...

SET OutputRoot.XML.Arrest.ActivitySuspect.PersonPhysicalDetails.OtherPersonPhysicalFeature[]=(SELECT R.PhysicalFeatureCategoryText,R.PhysicalFeatureLocationText,R.PhysicalFeatureDescriptionText FROM InputBody.Arrests.Arrest[I].OtherPersonPhysicalCharacter.OtherPersonPhysicalCharacter_ROW[] AS R);
DECLARE OtherRef REFERENCE = OutputRoot.XML.Arrest.ActivitySuspect.PersonPhysicalDetails.OtherPersonPhysicalFeature[];
DETACH OtherRef;
ATTACH OtherRef TO OutputRoot.XML.Arrest.PersonPhysicalDetails.PersonPhysicalFeature[] AS LASTCHILD;
????
Back to top
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Wed Apr 28, 2004 2:44 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You could also use Insert.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
klabran
PostPosted: Wed Apr 28, 2004 3:31 pm    Post subject: Reply with quote

Master

Joined: 19 Feb 2004
Posts: 259
Location: Flagstaff AZ

Can't seem to find info on insert except for database inserts...
Back to top
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Wed Apr 28, 2004 4:01 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It works just as well on message trees.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
klabran
PostPosted: Wed Apr 28, 2004 4:11 pm    Post subject: Reply with quote

Master

Joined: 19 Feb 2004
Posts: 259
Location: Flagstaff AZ

I am getting a compile error....

Complaining that it expects database.table...

This is my test that caused the error...

Insert into outputroot.arrest (Test,Test1) values('t','t1');

kevin
Back to top
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Wed Apr 28, 2004 4:54 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Hrm.

It looks like it doesn't work on message trees in v5...

You should be able to nest Selects to do what you want, I think.

Or you could always just loop over the children of both and do a manual join.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
klabran
PostPosted: Thu Apr 29, 2004 6:05 am    Post subject: Reply with quote

Master

Joined: 19 Feb 2004
Posts: 259
Location: Flagstaff AZ

How would I do a nested select to solve this....

The nested selects I see in the esql 2.1 manual all show that it would nest another tree instead of just another personphysicalfeature?

I was hoping to avoid the loop through all the records and manually add another personphysicalfeatue node....
Back to top
View user's profile Send private message Visit poster's website
klabran
PostPosted: Thu Apr 29, 2004 7:24 am    Post subject: Reply with quote

Master

Joined: 19 Feb 2004
Posts: 259
Location: Flagstaff AZ

Well here's my breakdown of my attempts and what I have currently working...

Working but I hope there is a better way....????

SET OutputRoot.XML.Arrest.ActivitySuspect.PersonPhysicalDetails.PersonPhysicalFeature[]=(SELECT R.PhysicalFeatureCategoryText,R.PhysicalFeatureLocationText,R.PhysicalFeatureDescriptionText FROM InputBody.Arrests.Arrest[I].PersonPhysicalFeature.PersonPhysicalFeature_ROW[] AS R);
DECLARE CNT INTEGER;
DECLARE EXISTFEATURE INTEGER;
SET EXISTFEATURE= (SELECT COUNT(*) FROM OutputRoot.XML.Arrest.ActivitySuspect.PersonPhysicalDetails.PersonPhysicalFeature[]);
SET CNT = 1;
--Combine any Other Features
WHILE CNT <= (SELECT COUNT(*) FROM InputBody.Arrests.Arrest[I].OtherPersonPhysicalCharacter.OtherPersonPhysicalCharacter_ROW[] AS OtherNum) DO
SET OutputRoot.XML.Arrest.ActivitySuspect.PersonPhysicalDetails.PersonPhysicalFeature[EXISTFEATURE + CNT]=(SELECT R.PhysicalFeatureCategoryText,R.PhysicalFeatureLocationText,R.PhysicalFeatureDescriptionText FROM InputBody.Arrests.Arrest[I].OtherPersonPhysicalCharacter.OtherPersonPhysicalCharacter_ROW[CNT] AS R);
SET CNT = CNT + 1;
END WHILE;

Attempted....

DETACH/ATTACH

Result -> Still had the issue where the OtherPersonPhysicalFeature tag was in the message tree. I would have to do additional work to remove this... Yuck!

INSERT

Result -> Recieved compile error. Seems in MQSI 2.1 we can't do INSERT statements on a message tree only DB's.

Nested Selects

Result -> Never tried because samples in ESQL 2.1 ref. seemed to show me that it would not give me the desired result.

I posted this only because I am a rookie at MQSI but not to programming. I want to learn several techniques for solving a problem to help discover which techniques work best where. Hopefully, others will learn from this also.

Thanks for all your help jefflowrey!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Combine two XML incoming repeatable tags into one
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.