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 » Chunk an XML file in message broker

Post new topic  Reply to topic
 Chunk an XML file in message broker « View previous topic :: View next topic » 
Author Message
ashritha
PostPosted: Thu Dec 15, 2005 12:51 pm    Post subject: Chunk an XML file in message broker Reply with quote

Voyager

Joined: 25 Jul 2005
Posts: 85

Hi,

I have an XML file coming in as an input. My message flow has to publish the information on a topic.

Now, say the input message that comes in has info related to 10 incidents. Incident is a sub-schema of the main file and the max occurances of this sub-schema is unbounded.

I have to publish these 10 sub-schemas as individual xml files on the topics. So, i have to chunk the input file into 10 pieces and have them published as 10 different XML files. All the 10 pieces of the input file may not have the same schema. My question is how do i chunk the input file and make them as individual xml files with in message broker.


I am working with Message Broker v6.0 on Windows XP

Any ideas?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Dec 15, 2005 1:00 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

The word you are looking for is not "chunk".

The word you are looking for is "propagate".

And what I mean is, you should now search for the word propagate.

And then spend the next hour or so reading all of the hits.

Before you follow up to this message with another question.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
ashritha
PostPosted: Thu Dec 15, 2005 2:28 pm    Post subject: Reply with quote

Voyager

Joined: 25 Jul 2005
Posts: 85

I guess my logic is not well-understood.....

I am not at the stage of PROPAGATING the messages in my message flow.
I am still at the beginning of cutting my large file into smaller files and building them as individual XML messages. Once I have these smaller files then I would be going for PROPAGATING them to my output.

I know how to use a PROPAGATE statement with a RETURN statement following it which would accomplish my process of sending the individual files for publishing.

But I am one step before propagating. I need to build individual files out of one big input file.

Writing a java code to split the file into smaller pieces is one solution but I was curious if there is any other way around because my input file has the same sub-schema being repeated n number of times and i have to chunk these into n different files.

Thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Dec 15, 2005 4:15 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Okay.

So, the typical use of propagate is this.

Write a loop in ESQL over the repeating part of the input message, that
needs to be broken out.

Remember that propagate clears the message tree at every stage, so you
always start with an empty output message.

Inside your loop, you will copy message headers. Then you will build a
new output message tree using the appropriate parts of the Input
message.

Then you will propagate, and loop back again.

As in any looping situation, the best way to start is to figure out what you
need to do for the first thing in the loop. So if you had to only process a
message with a single "smaller file" in it, what code would you write?

Then put that code for building the smaller file inside the loop, and adjust
it so that it uses the loop variables to get the right piece of the input
message, and knows how to properly halt the loop.

So, suppose at a basic level that your input message looked like this:

<body>
<header>abcd</header>
<data>123</data>
<data>123</data>
<footer>wxyz</footer>
</body.

then you would write ESQL kind of like thise
Code:

declare myRef reference to InputRoot.body.data[1];
While lastmove(myref)
    CopyMessageHeaders();
    Set OutputRoot.XML..body.header = InputRoot.XML.body.header;
    Set OutputRoot.body.XML.data = myref;
    Set OutputRoot.XML.footer = InputRoot.XML.body.footer;
    propagate;
    move myRef nextsibling myRef;
end while;
return FALSE;


Again, in a very general sense.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
ashritha
PostPosted: Tue Dec 27, 2005 10:43 am    Post subject: Reply with quote

Voyager

Joined: 25 Jul 2005
Posts: 85

Hi Jeff,

Sorry for the late reply but the code you sent works for me with one exception.

In the While loop, for the first iteration I get a new xml file generated for the first data value(specified in your example), but in the second iteration i get an xml file with no value for only the header and footer and no value for the frerence variable. The third iteration generates an XML with the second data value.

For example, I should be getting 2 different XML files for the 2 data values in the input while i am getting 4 XML files with alternate null XML files(with only header and footer and no data).

Is there anything missing???

I am unable to view this in the debug after the first iteration as it does not give me an option to get back into the code after the PROPAGATE statement.

Any Help!!!
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Dec 27, 2005 11:00 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Ah.

I think you are running into XML that has blank lines in it.

The XML Parser registers those as sibling elements. So the move statement causes the reference to point to them.

You can use the type clause of the move to solve this, so you are only going to XML.Elements, or XML.Attributes or whatever.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
ashritha
PostPosted: Tue Dec 27, 2005 12:24 pm    Post subject: Reply with quote

Voyager

Joined: 25 Jul 2005
Posts: 85

Hi Jeff,

It worked. Thanks a lot.

I just modified the MOVE statement and it worked.

The new statement is

Quote:
MOVE myRef NEXTSIBLING REPEAT TYPE NAME;


and this worked.

Once again thanks so much.
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 » Chunk an XML file in message broker
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.