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 » Java Compute Node

Post new topic  Reply to topic
 Java Compute Node « View previous topic :: View next topic » 
Author Message
trinath
PostPosted: Sun Sep 21, 2014 11:33 pm    Post subject: Java Compute Node Reply with quote

Apprentice

Joined: 02 Jun 2014
Posts: 34

Hello Please Provide code for changing one xml to different xml by using Java compute node


My Requirement like:

am giving input like this
<Employees>

<Employee>
<Name> john </Name>
<Number> 1 </Number>
<Salary> 5000 </Salary>
</Employee>

<Employee>
<Name>Ram</Name>
<Number> 2</Number>
<Salary> 6000 </Salary>
</Employee>

</Employees>
-----------------------------

am accepting output like this
<Employees>
<Employee>
john with id 1 getting salary 5000
</Employee>

<Employee>
Ram with id 2 getting salary 6000
</Employee>

</Employees>
--------------------
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Sep 22, 2014 12:20 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

What have you tried?
What went wrong?

This is very easy using ESQL
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
trinath
PostPosted: Mon Sep 22, 2014 12:53 am    Post subject: Reply with quote

Apprentice

Joined: 02 Jun 2014
Posts: 34

It is easy in esql, but i need in java with the help of java compute node.
Back to top
View user's profile Send private message
vicentius
PostPosted: Mon Sep 22, 2014 1:50 am    Post subject: Reply with quote

Apprentice

Joined: 01 Mar 2013
Posts: 28

Please share with us your context, so we can help. As smdavies already mentioned, let us know what have you tried so far, let us know where you got stuck.
You will find it easy to get help to the issues you encounter, but not many people will jump in to write *your* code. Understand that people around online communities like to help out, but they generally have limited time to invest in such activities for free.
Back to top
View user's profile Send private message
trinath
PostPosted: Mon Sep 22, 2014 2:21 am    Post subject: Reply with quote

Apprentice

Joined: 02 Jun 2014
Posts: 34

===> Input flile


<Employees>
<Employee>
<Name>John</Name>
<Number>1</Number>
</Employee>
<Employee>
<Name>shreeya</Name>
<Number>2</Number>
</Employee>

</Employees>


===> Expected Out Put


<Employees>
<Employee> John with id 1 </Employee>
<Employee> shreeya with id 2 </Employee>
</Employees>


am trying this code
----------------------


// Add user code below

MbElement inRoot = inMessage.getRootElement().getLastChild();

MbElement firstEle = inRoot.getFirstElementByPath("Employees/Employee").getFirstChild();
String firstEle1 = (String)firstEle.getValue();

MbElement lastEle = inRoot.getFirstElementByPath("Employees/Employee").getLastChild();
String lastEle1 = (String)lastEle1.getValue();


MbElement firstEle2 = inRoot.getFirstElementByPath("Employees/Employee").getNextSibling().getFirstChild();
String firstEle22 = (String)firstEle2.getValue();

MbElement lastEle2 = inRoot.getFirstElementByPath("Employees/Employee").getNextSibling().getLastChild();
String lastEle22 = (String)lastEle2.getValue();



String total = "<Employee>" + firstEle1+" " + "with id" + " " + lastEle1 + "</Employee>" ;
String total1 = "<Employee>" +firstEle22+" " + "with id" + " " + lastEle22 + "</Employee>" ;

String aa= "<Employees>"+total+total1 +"</Employees>";

MbElement outRoot = outMessage.getRootElement();
MbElement outParser = outRoot.createElementAsLastChild(MbBLOB.PARSER_NAME);

MbElement outBodyEl2 = outParser.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", aa.getBytes());


// End of user code

it is working but,how to use looping conditions in this code for accessing multiple childs in every sibling
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Sep 22, 2014 5:09 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Ok, so why are you building a message string, instead of copying elements from one MbRoot to another?

Why are you building a string, rather than creating new MbElements?

Have you reviewed the Mb Java API docs? The samples?
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Sep 22, 2014 6:52 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

mqjeff wrote:


Why are you building a string, rather than creating new MbElements?



Perhaps the poster wants to make life difficult for themselves. Having to use Java is probably not enough torture.

{ducks to avoid incoming brickbats}
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
vicentius
PostPosted: Mon Sep 22, 2014 7:28 am    Post subject: Reply with quote

Apprentice

Joined: 01 Mar 2013
Posts: 28

mqjeff wrote:
[...]Why are you building a string, rather than creating new MbElements?[...]


Probably working with the same mindset as creating fields in ESQL using SET instead of CREATE.
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 » Java Compute Node
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.