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 » Converting Name Value pair to XML

Post new topic  Reply to topic
 Converting Name Value pair to XML « View previous topic :: View next topic » 
Author Message
jeevan
PostPosted: Tue Jan 09, 2007 7:09 pm    Post subject: Converting Name Value pair to XML Reply with quote

Grand Master

Joined: 12 Nov 2005
Posts: 1432

Can some one give me some idea how I can code esql for converting name value pair to xml.

I have created two variables to store name and values from input as follows:

SET myName = InputBody.Record[1].Name;
SET myValue= InputBody.Record[1].Value;

Then i do esql coding as follows:

IF first_child = TRUE THEN
CREATE FIRSTCHILD OF OutputRoot.XML.RootElement DOMAIN ('XML') NAME myName Value myValue;
SET childname = myValue;
SET first_child = FALSE;
ELSE
CREATE NEXTSIBLING OF OutputRoot.XML.RootElement.{childname} DOMAIN ('XML') NAME myName Value myValu;
SET childname = myName;
END IF;


The out put is follows:


<RootElement>
<Name>FIRSTNAME</Name>
<Value>Jeevan</Value>
</RootElement>

But what i want is as follows:

<RootElement>
<FIRSTNAME> Jeevan </FIRSTNAME>
</RootElement>

thanks
Back to top
View user's profile Send private message
vsr
PostPosted: Tue Jan 09, 2007 9:29 pm    Post subject: Reply with quote

Centurion

Joined: 04 Apr 2006
Posts: 104

I don't see anything wrong in the code and I am getting the output you wanted using your same esql statements ...

When I pass input as
<Record>
<Name>FIRSTNAME</Name>
<Value>Jeevan</Value>
</Record>

I am getting the output ( I used same esql you coded ! )

Code:
CREATE FIRSTCHILD OF OutputRoot.XML.RootElement DOMAIN ('XML') NAME myName Value myValue;


<RootElement>
<FIRSTNAME> Jeevan </FIRSTNAME>
</RootElement>

May be I didn't understand the problem .. can you elaborate on what input you are passing and output for that
Back to top
View user's profile Send private message
jeevan
PostPosted: Tue Jan 09, 2007 9:53 pm    Post subject: Reply with quote

Grand Master

Joined: 12 Nov 2005
Posts: 1432

My input is name value pair data as

FirstName=Jeevan
MI=K
LastName=sharma

I developed a msgset to read it correctly. I am only having problem in converting it to xml which should be straight forward.


My input tree is like follows:

MRM
Record
name = firstname
value =jeevan
record
name = mi
value = K

and so on


My esql code to generate output in xml format is as follows:

SET myname = InputBody.Record[1].Name;
SET myvalue= InputBody.Record[1].Value;


IF first_child_flag = TRUE THEN
CREATE FIRSTCHILD OF OutputRoot.XML.RootElement DOMAIN ('XML') NAME myname VALUE myvalue;
SET first_child_flag = FALSE;
ELSE
CREATE NEXTSIBLING OF OutputRoot.XML.RootElement.{childname} DOMAIN ('XML') NAME myname VALUE myvalue;
END IF;


It does not work.

Hope you understand it.

thanks
Back to top
View user's profile Send private message
jeevan
PostPosted: Tue Jan 09, 2007 10:23 pm    Post subject: Reply with quote

Grand Master

Joined: 12 Nov 2005
Posts: 1432

When I walked through the code, it gives error in the following line


CREATE FIRSTCHILD OF OutputRoot.XML.RootElement DOMAIN ('XML') NAME myname VALUE myvalue;

But i could not see any error in this line. Appreciate your help

thanks
Back to top
View user's profile Send private message
gregop
PostPosted: Wed Jan 10, 2007 12:12 am    Post subject: Reply with quote

Voyager

Joined: 24 Nov 2006
Posts: 81

Quote:
When I walked through the code, it gives error in the following line


CREATE FIRSTCHILD OF OutputRoot.XML.RootElement DOMAIN ('XML') NAME myname VALUE myvalue;


What error does it give ?

What does OutputRoot.XML look like before the statement?

It should contain RootElement at that point.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jan 10, 2007 1:14 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Hi Jeevan,

A couple of hints:

- You should be using the XMLNSC domain if you are designing a new message flow in v6 ( XML domain is very old, and not actively maintained ).
- You do not need to specify the DOMAIN clause on child elements and it can cause a memory leak if you do. The DOMAIN clause is intended for use when creating a root node in the environment tree.
- You have a typo in your CREATE NEXTSIBLING line ( 'myValu' ).
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 » Converting Name Value pair to 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.