| Author | 
		  Message
		 | 
		
		  | shwe | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 5:35 am    Post subject: Namespace in XML Message Body | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 28 Dec 2012 Posts: 13
  
  | 
		  
		    
			  
				Hi,
 
 
I have to generate an XML file in the below format
 
 
 <?xml version="1.0" encoding="UTF-8" ?> 
 
<IR001A 
 
xsi:schemaLocation="http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd" xmlns="http://apisit.hr/b28/inst/ed/2011/ir001a" xmlns:ct="http://apisit.hr/b28/inst/ed/2011/complexTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
<Envelope>
 
 <Header>
 
  <FlowOfGoods>1</FlowOfGoods> 
 
   <PSI>
 
     <ct:PSIId>
 
         <ct:PSICountryCode>HR</ct:PSICountryCode> 
 
     <ct:PSIId>
 
   </PSI>
 
 </Header>
 
</IR001A>
 
<Envelope>
 
 
I am able to get the headers right, but problem is while generating the message body with namespace.
 
 
This is my ESQL code
 
 
DECLARE ct NAMESPACE 'http://apisit.hr/b28/inst/ed/2011/complexTypes';
 
		
 
		SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xsi:schemaLocation" value ='http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd';
 
		
 
		SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlnsc:ct" value = ct;
 
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlns:xsi" value = 'http://www.w3.org/2001/XMLSchema-instance';
 
		SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlnsc" value = 'http://apisit.hr/b28/inst/ed/2011/ir001a';
 
 
SET outRef.IR001A.Envelope.Header.FlowOfGoods = 'A';
 
		
 
SET outRef.IR001A.Envelope.Header.PSI.ct:"PSIId".ct:"PSICountryCode" ='SK987';
 
 
This is generating output as
 
 
<?xml version="1.0" encoding="UTF-8"?>
 
<IR001A xsi:schemaLocation="http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd" xmlnsc:ct="http://apisit.hr/b28/inst/ed/2011/complexTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlnsc="http://apisit.hr/b28/inst/ed/2011/ir001a">
 
 <Envelope>
 
  <Header>
 
   <FlowOfGoods>A</FlowOfGoods>
 
   <PSI>
 
    <NS1:PSIId xmlns:NS1="http://apisit.hr/b28/inst/ed/2011/complexTypes">
 
     <NS1:PSICountryCode>SK987</NS1:PSICountryCode>
 
    </NS1:PSIId>
 
   </PSI>
 
  </Header>
 
 </Envelope>
 
</IR001A>
 
 
How do I get rid of NS1 and namespace and get ct instead in the message body? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 5:41 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				- Why do you want to?  Is it strictly necessary?  Are you really really really sure?
 - You need to add the necessary parts of the logical message tree to describe the "xmlns:ct="http://apisit.hr/b28/inst/ed/2011/complexTypes" " data
 
  | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | shwe | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 5:48 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 28 Dec 2012 Posts: 13
  
  | 
		  
		    
			  
				1) This is the requirement from client, so it is a necessary
 
 
2) Can you please tell me what are the necessary parts that needs to be added? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 5:49 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				| Search for 'XMLNSC namespace declaration' in the info center. It is described in detail, with examples. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 6:09 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				
   
	| shwe wrote: | 
   
  
	| 1) This is the requirement from client, so it is a necessary | 
   
 
 
Have you had a conversation with them about why they made it a requirement? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | vishnurajnr | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 6:30 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 08 Aug 2011 Posts: 134 Location: Trivandrum 
  | 
		  
		    
			  
				if you use 
 
 Instead of 
 
 it will fix your issue.
 
 
But I think its not a recommended style.   _________________ -------
 
A man is great by deeds, not by birth...! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 6:31 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| vishnurajnr wrote: | 
   
  
	if you use 
 
 Instead of 
 
 it will fix your issue. | 
   
 
 
 
How?
 
 
   
	| vishnurajnr wrote: | 
   
  
	But I think its not a recommended style.   | 
   
 
 
 
Very not recommended. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 6:33 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				
   
	| Vitor wrote: | 
   
  
	
   
	| vishnurajnr wrote: | 
   
  
	But I think its not a recommended style.   | 
   
 
 
 
Very not recommended. | 
   
 
 
especially when it's not a terribly meaningful issue and there's also direct, clear, easily findable examples of how to "fix" it without doing anything drastic.
 
 
Please don't use XMLNS parser. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 6:34 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				| @vishnurajnr: That advice is 100% incorrect. I have no idea why you think that using the XMLNS parser will make any difference. It will not. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | vishnurajnr | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 7:22 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 08 Aug 2011 Posts: 134 Location: Trivandrum 
  | 
		  
		    
			  
				Sorry, if I overlook into the Post.
 
 
I think the OP's Code is missing the NameSpace setting.
 
 
   
	| Code: | 
   
  
	| SET OutputRoot.XMLNSC.IR001A.(XMLNSC.NamespaceDecl)xmlns:ct  = ct; | 
   
 
 _________________ -------
 
A man is great by deeds, not by birth...! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 7:25 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				No, that's still incorrect. Thanks for trying   | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | vishnurajnr | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 7:34 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 08 Aug 2011 Posts: 134 Location: Trivandrum 
  | 
		  
		    
			  
				Have tried the OP's code except the above change:
 
   
	| Code: | 
   
  
	DECLARE ct NAMESPACE 'http://apisit.hr/b28/inst/ed/2011/complexTypes';
 
 
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xsi:schemaLocation" value ='http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd';
 
[b]SET OutputRoot.XMLNSC.IR001A.(XMLNSC.NamespaceDecl)xmlns:ct  = ct;[/b]
 
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlns:xsi" value = 'http://www.w3.org/2001/XMLSchema-instance';
 
SET OutputRoot.XMLNSC.IR001A.(XMLNSC.Attribute)"xmlnsc" value = 'http://apisit.hr/b28/inst/ed/2011/ir001a';
 
 
DECLARE outRef REFERENCE    TO OutputRoot.XMLNSC;      
 
SET outRef.IR001A.Envelope.Header.FlowOfGoods = 'A';
 
SET outRef.IR001A.Envelope.Header.PSI.ct:"PSIId".ct:"PSICountryCode" ='SK987';  | 
   
 
 
 
It produce the Output as :
 
   
	| Code: | 
   
  
	<IR001A xsi:schemaLocation="http://apisit.hr/b28/inst/ed/2011/ir001a instIr001a.xsd" xmlns:ct="http://apisit.hr/b28/inst/ed/2011/complexTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlnsc="http://apisit.hr/b28/inst/ed/2011/ir001a">
 
 <Envelope>
 
  <Header>
 
   <FlowOfGoods>A</FlowOfGoods>
 
   <PSI>
 
    <ct:PSIId>
 
     <ct:PSICountryCode>SK987</ct:PSICountryCode>
 
    </ct:PSIId>
 
   </PSI>
 
  </Header>
 
 </Envelope>
 
</IR001A>  | 
   
 
 
 
So How..??
 
 
   _________________ -------
 
A man is great by deeds, not by birth...! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 7:41 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				You're right. I read your line of code as 
   
	| Code: | 
   
  
	| SET OutputRoot.XMLNSC.IR001A.(XMLNSC.NamespaceDecl)xmlns:ct  = "ct"; | 
   
 
Sorry for the false alarm. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | shwe | 
		  
		    
			  
				 Posted: Wed Jun 26, 2013 11:08 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 28 Dec 2012 Posts: 13
  
  | 
		  
		    
			  
				Thanks all for the reply.
 
 
I got the solution as per vishnurajnr's advice, by declaring the Nameapce rightly. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |