| Author | Message | 
		
		  | JawedImran | 
			  
				|  Posted: Tue Dec 24, 2013 11:00 am    Post subject: not able to create Attributes in ESQL |   |  | 
		
		  | Newbie
 
 
 Joined: 15 Aug 2013Posts: 5
 
 
 | 
			  
				| Hi All, 
 I am new in message broker, getting problem while creating attributes in xml node using MB7.
 
 Element Value is getting override and attributes are not creating as expected.
 
 Input:
 
 
   
	| Code: |  
	| <ns1:Application>
 <ns1:Attachments>
 <ns1:DocumentId>55</ns1:DocumentId>
 <ns1:DocumentPages>1</ns1:DocumentPages>
 <ns1:DocumentType>PDF</ns1:DocumentType>
 <ns1:TaxonomyDocType>12</ns1:TaxonomyDocType>
 <ns1:Attachment>abcd</ns1:Attachment>
 </ns1:Attachments>
 <ns1:Attachments>
 <ns1:DocumentId>56</ns1:DocumentId>
 <ns1:DocumentPages>2</ns1:DocumentPages>
 <ns1:DocumentType>PDF</ns1:DocumentType>
 <ns1:TaxonomyDocType>13</ns1:TaxonomyDocType>
 <ns1:Attachment>abcd</ns1:Attachment>
 </ns1:Attachments>
 </ns1:Application>
 
 
 DECLARE application REFERENCE TO InputRoot.SOAP.Body.nsCntt:Application;
 
 CREATE FIELD OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ns1:Application;
 DECLARE outApp REFERENCE TO OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ns1:Application;
 
 FOR applicationAttachments AS application.ns1:Attachments[] DO
 DECLARE outAttachment REFERENCE TO OutputRoot;
 CREATE LASTCHILD OF outApp AS outAttachment NAMESPACE ns1 NAME 'Attachments';
 
 SET outAttachment = applicationAttachments.ns1:DocumentId; -- creating Attachments node value
 SET outAttachment.(XMLNSC.Attribute)DocumentPages = applicationAttachments.nsCntt:DocumentPages; --adding attribute
 SET outAttachment.(XMLNSC.Attribute)DocumentType = applicationAttachments.nsCntt:DocumentType; --adding attribute
 SET outAttachment.(XMLNSC.Attribute)TaxonomyDocType = applicationAttachments.nsCntt:DocumentType; --adding attribute
 
 END FOR;
 
 OutPut:
 <ns1:Application>
 <ns1:Attachments DocumentPages="1" DocumentType="PDF" TaxonomyDocType="12" >55</ns1:Attachments>
 <ns1:Attachments DocumentPages="2" DocumentType="PDF" TaxonomyDocType="13" >56</ns1:Attachments>
 </ns1:Application>
 |  
 Last edited by JawedImran on Tue Dec 24, 2013 12:18 pm; edited 2 times in total
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | JawedImran | 
			  
				|  Posted: Tue Dec 24, 2013 11:05 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 15 Aug 2013Posts: 5
 
 
 | 
			  
				| Even I tried with below code but same issue. 
 DECLARE application REFERENCE TO InputRoot.SOAP.Body.nsCntt:Application;
 
 
   
	| Code: |  
	| CREATE FIELD OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ns1:Application;
 DECLARE outApp REFERENCE TO OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ns1:Application;
 DECLARE j INTEGER 1;
 FOR applicationAttachments AS application.ns1:Attachments[] DO
 
 SET outApp.ns1:Attachments[j] = applicationAttachments.ns1:DocumentId; -- creating Attachments node value
 SET outApp.ns1:Attachments[j].(XMLNSC.Attribute)DocumentPages = applicationAttachments.nsCntt:DocumentPages; --adding attribute
 SET outApp.ns1:Attachments[j].(XMLNSC.Attribute)DocumentType = applicationAttachments.nsCntt:DocumentType; --adding attribute
 SET outApp.ns1:Attachments[j].(XMLNSC.Attribute)TaxonomyDocType = applicationAttachments.nsCntt:DocumentType; --adding attribute
 SET j = j + 1;
 END FOR;
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Wed Dec 25, 2013 1:04 am    Post subject: Re: not able to create Attributes in ESQL |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| 
   
	| JawedImran wrote: |  
	| 
   
	| Code: |  
	| DECLARE application REFERENCE TO InputRoot.SOAP.Body.nsCntt:Application;
 
 CREATE FIELD OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ns1:Application;
 DECLARE outApp REFERENCE TO OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ns1:Application;
 
 FOR applicationAttachments AS application.ns1:Attachments[] DO
 DECLARE outAttachment REFERENCE TO OutputRoot;
 CREATE LASTCHILD OF outApp AS outAttachment NAMESPACE ns1 NAME 'Attachments';
 
 SET outAttachment = applicationAttachments.ns1:DocumentId; -- creating Attachments node value
 SET outAttachment.(XMLNSC.Attribute)DocumentPages = applicationAttachments.nsCntt:DocumentPages; --adding attribute
 SET outAttachment.(XMLNSC.Attribute)DocumentType = applicationAttachments.nsCntt:DocumentType; --adding attribute
 SET outAttachment.(XMLNSC.Attribute)TaxonomyDocType = applicationAttachments.nsCntt:DocumentType; --adding attribute
 
 END FOR;
 
 OutPut:
 <ns1:Application>
 <ns1:Attachments DocumentPages="1" DocumentType="PDF" TaxonomyDocType="12" >55</ns1:Attachments>
 <ns1:Attachments DocumentPages="2" DocumentType="PDF" TaxonomyDocType="13" >56</ns1:Attachments>
 </ns1:Application>
 |  |  
 Your code ; DECLARE outAttachment REFERENCE TO OutputRoot;...
 I'm sure you meant to say something like
 
 
   
	| Code: |  
	| CREATE LAST CHILD OF outapp as outAttachment Namespace... Name 'Attachments'; |  
 That's not the only thing... did you check the lastmove(outapp) after assigning outapp?
 Have fun
    _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | JawedImran | 
			  
				|  Posted: Wed Dec 25, 2013 11:50 pm    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 15 Aug 2013Posts: 5
 
 
 | 
			  
				| Hi Saper, 
 Thanks for Quick response.
 
 Yeah I tried with LastMove also.
 
 Even I tried with Simple FOR loop logic but same issue. attribute are not getting created.
 
 
   
	| Code: |  
	| DECLARE application REFERENCE TO InputRoot.SOAP.Body.nsCntt:Application;
 
 CREATE FIELD OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ns1:Application;
 DECLARE outApp REFERENCE TO OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ns1:Application;
 DECLARE j INTEGER 1;
 FOR applicationAttachments AS application.ns1:Attachments[] DO
 
 SET outApp.ns1:Attachments[j] = applicationAttachments.ns1:DocumentId; -- creating Attachments node value
 SET outApp.ns1:Attachments[j].(XMLNSC.Attribute)DocumentPages = applicationAttachments.nsCntt:DocumentPages; --adding attribute
 SET outApp.ns1:Attachments[j].(XMLNSC.Attribute)DocumentType = applicationAttachments.nsCntt:DocumentType; --adding attribute
 SET outApp.ns1:Attachments[j].(XMLNSC.Attribute)TaxonomyDocType = applicationAttachments.nsCntt:DocumentType; --adding attribute
 SET j = j + 1;
 END FOR;
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | smdavies99 | 
			  
				|  Posted: Thu Dec 26, 2013 3:08 am    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 10 Feb 2003Posts: 6076
 Location: Somewhere over the Rainbow this side of Never-never land.
 
 | 
			  
				| Please use [ C O D E ] tags around your code 
 What does a usertrace show when executing the ESQL you posted?
 You say they are not being created. Ok, what is or isn't being created?
 _________________
 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 |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Thu Dec 26, 2013 6:58 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| And sorry, but your code does not show you checking for lastmove(cursor) after defining a cursor... You do know that you have to do that right?
    _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kimbert | 
			  
				|  Posted: Fri Dec 27, 2013 9:03 am    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 29 Jul 2003Posts: 5543
 Location: Southampton
 
 | 
			  
				| I can help you with this, but please do the following: - add [ C O D E ] tags around your XML and ESQL snippets. It is very hard to read them otherwise. There is an [ edit ] button that you can use to do that ( when you have logged in ).
 - provide an example of the output that you want, and the output that your flow is producing. Then we will be able to see what is wrong.
 _________________
 Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Fri Dec 27, 2013 10:38 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| Wrapped the code with tags... Sorry to say but your code does exactly what you are telling it to do....
 
 Have you tried changing following line
 
 
   
	| Code: |  
	| SET outAttachment = applicationAttachments.ns1:DocumentId; -- creating Attachments node value |  
 to
 
 
   
	| Code: |  
	| SET outAttachment.(XMLNSC.Attribute)DocumentId = applicationAttachments.ns1:DocumentId; -- creating Attachments node value |  Maybe that would be closer to what you're looking for...
    _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |