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 » Splitting large XML file into individual XML

Post new topic  Reply to topic
 Splitting large XML file into individual XML « View previous topic :: View next topic » 
Author Message
hellobond070
PostPosted: Thu Apr 29, 2010 7:50 pm    Post subject: Splitting large XML file into individual XML Reply with quote

Centurion

Joined: 18 Nov 2009
Posts: 118

hi,

I have a XML which looks like below :

<Message>
<Child>abcde</Child>
<Child>sdlfkjl</Child>
<Child>defgh</Child>
</Message>

I have a break this message into individual outputs like below:
OUtput 1
<Message>
<Child>abcde></Child>
</Message>

OUtput2
<Message>
<Child>sdlfkjl></Child>
</Message>

Output3
<Message>
<Child>defgh</Child>
</Message>

Please let me know if this is possible to do without using a output message set by just using ATTACH and DETACH esql statements.
Also, if there is any other alternative way but without using any message set creation i.e. just by using ESQL code.

THanks.
Back to top
View user's profile Send private message
fatherjack
PostPosted: Fri Apr 30, 2010 6:19 am    Post subject: Re: Splitting large XML file into individual XML Reply with quote

Knight

Joined: 14 Apr 2010
Posts: 522
Location: Craggy Island

Yeah. Exactly like you say....

hellobond070 wrote:
just by using ESQL code.

_________________
Never let the facts get in the way of a good theory.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Apr 30, 2010 6:52 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Looks like you could do this using a loop with a PROPAGATE statement.

Why did you think a message set might be required? Why did you think ATTACH and DETACH might be required?
Back to top
View user's profile Send private message
hellobond070
PostPosted: Fri Apr 30, 2010 11:31 am    Post subject: Reply with quote

Centurion

Joined: 18 Nov 2009
Posts: 118

Well if you just do a loop and propagate, it will propagate the full XML message and not just what is there in the loop. This was my understanding.

I then found a piece code as below ;

DECLARE i INTEGER 1;
DECLARE count INTEGER;
SET count = CARDINALITY(InputRoot.XMLNS.Invoice.Purchases."Item"[])

WHILE i <= count DO
--use the default tooling-generated procedure for copying message headers
CALL CopyMessageHeaders();
SET OutputRoot.XMLNS.BookSold.Item = InputRoot.XMLNS.Invoice.Purchases.Item[i];
PROPAGATE;
SET i = i+1;
END WHILE;
RETURN FALSE;


And yes Kimbert, I could achieve this using PROPAGATE.
Well message set can also help, provided we have it. Well ATTACH and DETACH is not solving my issue. I tried coding using this but it's not working.

Thanks for your support everyone.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Apr 30, 2010 11:37 am    Post subject: Reply with quote

Grand High Poobah

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

hellobond070 wrote:
Well ATTACH and DETACH is not solving my issue. I tried coding using this but it's not working.


Not working how? Throwing an error or just not doing what you expect? Can you post further details?

Also here's a tip: don't use CARDINALITY. Use MOVE and LASTMOVE, it's far more efficient especially when you're traversing a large piece of XML as you are. If you reference element [i] as you are WMB will start at 1 each time and go through i-1 elements to find it.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
hellobond070
PostPosted: Sat May 01, 2010 8:50 am    Post subject: Reply with quote

Centurion

Joined: 18 Nov 2009
Posts: 118

Well my problem is to convert

Quote:
<Message>
<Child>abcde</Child>
<Child>sdlfkjl</Child>
<Child>defgh</Child>
</Message>


to 3 output messages as posted before. I first use SET OutputRoot=InputRoot and assign the child array to a reference. Now I have no way to detach each of the child from the reference and attach it to the OutputRoot and keep propagating it through the out terminal.

I wish, I had the code which I deleted since the new code is working just fine without any issues.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Sat May 01, 2010 9:09 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

I wouldn't have copied everything to OutputRoot first, waste of effort.

It's really probably a bad idea to DETACH anything from input root, but if you really wanted to do it, that's how I'd do it. DETACH from InputRoot, ATTACH to OutputRoot, Propagate.

But other than switching InputRoot.XMLNS.Invoice.Purchases.Item[i] to use a REFERENCE variable, and using the XMLNSC parser instead of the XMLNS parser, there's nothing wrong with the code you have and it's the preferable method.
Back to top
View user's profile Send private message
hellobond070
PostPosted: Sat May 08, 2010 3:29 pm    Post subject: Reply with quote

Centurion

Joined: 18 Nov 2009
Posts: 118

Well yes Mqjeff.

I have finally converted the pasted piece of code to my requirement using XMLNSC.

I am really not sure whether we can use DETACH on the InputRoot. It's like manipulating the Input XML which according to me should not be possible. What I do know is that we can mess around with the outputRoot once we do SET OutputRoot = InputRoot in this case scenario.

I found the below text in infocenter which tells us more about usage of DETACH
Quote:
The following example illustrates how to use the ATTACH statement, together with the DETACH statement described in DETACH statement, to modify a message structure. The dynamic reference supplied to the DETACH statement must point to a modifiable message tree such as Environment, LocalEnvironment, OutputRoot, OutputExceptionList, or InputLocalEnvironment.
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 » Splitting large XML file into individual XML
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.