| Author | 
		  Message
		 | 
		
		  | jeevan | 
		  
		    
			  
				 Posted: Tue Jan 09, 2007 7:09 pm    Post subject: Converting Name Value pair to XML | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | vsr | 
		  
		    
			  
				 Posted: Tue Jan 09, 2007 9:29 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jeevan | 
		  
		    
			  
				 Posted: Tue Jan 09, 2007 9:53 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jeevan | 
		  
		    
			  
				 Posted: Tue Jan 09, 2007 10:23 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | gregop | 
		  
		    
			  
				 Posted: Wed Jan 10, 2007 12:12 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Wed Jan 10, 2007 1:14 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |