| Author | 
		  Message
		 | 
		
		  | alechko | 
		  
		    
			  
				 Posted: Tue Jul 08, 2008 12:14 am    Post subject: Generating XML encoded message | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Jan 2005 Posts: 37
  
  | 
		  
		    
			  
				Hi,
 
 
I'm trying to develop a flow that generates an xml message,
 
wraps it with a header xml but transforms the original xml message to encoded form with entity references. 
 
I'll explain:
 
 
Let's say I have the following xml message:
 
   
	| Code: | 
   
  
	| <message>123</message> | 
   
 
 
 
I want to generate the following message:
 
   
	| Code: | 
   
  
	<GeneratedMessage><message>123</message></GeneratedMessage>
 
 | 
   
 
 
 
Is there are an elegant way to do this?
 
I thought about using some java code ...
 
 
I'd appreciate any kind of help!
 
Alik | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Tue Jul 08, 2008 1:29 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				It could be that using CDATA is the way to go here.
 
 
Could you explain why you want the original message encoded in that way? _________________ 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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | sridhsri | 
		  
		    
			  
				 Posted: Tue Jul 08, 2008 5:27 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Master
 
 Joined: 19 Jun 2008 Posts: 297
  
  | 
		  
		    
			  
				| How about using ABITSTEAM and converting that XML message into a bitstream and then setting your envelope xml element's value to that bitstream ? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Tue Jul 08, 2008 5:44 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				sridhsri : That will not escape the XML markup characters, and it is not a good solution anyway. You should only use XML.AsisElementContent or XML.Bitstream when there is no other solution. 
 
Let's wait until alechko states his requirement. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | alechko | 
		  
		    
			  
				 Posted: Tue Jul 08, 2008 1:20 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Jan 2005 Posts: 37
  
  | 
		  
		    
			  
				First of all, thank you all for your quick replies.
 
 
This requirement is due to the fact that the xml message might contain xml characters such as "<"  and ">".
 
I agree that the best way to do so is using CDATA but ...
 
not all clients receiving and sending these message can generate or parse CDATA section.
 
 
Surprisingly enough, I found out the using ASBITSTREAM and afterwards "CREATE PARSE ..." as sridhsri suggested generated the whole string with "<" and ">".
 
Am I just plain lucky or is it the way it is supposed to work? Any other suggestions?
 
 
Thanks again,
 
Alik | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Wed Jul 09, 2008 12:43 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	| Am I just plain lucky or is it the way it is supposed to work? | 
   
 
It is designed behaviour, and required by the XML spec. The parser will automatically escape any XML markup characters which appear within the value of an element ( unless the element type is CDataSection ). Otherwise it might generate badly-formed XML documents.
 
 
If your inner message is in the form of a message tree, then ASBITSTREAM is the correct way to convert it to a string. I presume the CREATE...PARSE was just your method of checking that you had achieved your goals - not part of the solution. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |