| Author | 
		  Message
		 | 
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 9:28 am    Post subject: Reading XML Elements inside XML Message | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				Hi,
 
 
I have a scenario where I get XML Message in which Header part has senders information and body of XML Message contains a sub xml message. Below is the example
 
 
<?xmlversion......>
 
<Message>
 
<Message1>
 
<Messaged ID></MessageID>
 
<Data>
 
   <![CDATA[
 
    <?xml version ="1.0"..>
 
    <!DOCTYPE..?
 
    <Desc>
 
       <Emp>
 
           <.....>
 
           <.....>
 
       </Emp>
 
    </Desc> ]]>
 
/Data>
 
</Message1>
 
</Message>
 
 
Now my question is..How can I populate output message with  <Emp> element from the Input message dynamically.
 
<Emp> element changes as per the message, It might be <dept>,<dvision>...etc
 
 
How can I code to get the dynamcally changing message inside a message
 
 
InputRoot.XMLNS.Message.Message1.Data...?
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | elvis_gn | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 9:38 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 08 Oct 2004 Posts: 1905 Location: Dubai 
  | 
		  
		    
			  
				Hi Kumar4,
 
 
You can create an XML tree in the LocalEnvironment(using the Domain clause) of the entire CDATA....something like CREATE LASTCHILD OF xxx DOMAIN 'XMLNS' FROM <the CDATA path>
 
 
Then DETACH and ATTACH to the Output tree.
 
 
Regards. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 10:23 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				Hi,
 
 
Thanks for your response.
 
 
I understood the logic, But I dont want the <CDATA and Doc type declarations from the InputMessage, I just need <emp> from the <Data>
 
element and that too dynamically changing.
 
 
I created a child for LocalEnvironment with the CDATA position.
 
But when I access the LocalEnv it brings up the Doc type declarations which I dont need.
 
 
Am I understanding it correct?
 
Please brief ?
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | elvis_gn | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 10:45 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 08 Oct 2004 Posts: 1905 Location: Dubai 
  | 
		  
		    
			  
				Hi Kumar4,
 
 
So you are half way there, perhaps if you used a reference to FIRSTCHILD with the TYPE to element within this new tree you would get to your 'emp' dynamically.
 
 
Regards. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 10:52 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				Thanks
 
 
Below is my LocalEnvironment setting statement .
 
 
 
CREATE LASTCHILD OF InputLocalEnvironment DOMAIN 'XMLNS' FROM InputRoot.XMLNS.Messages.Message1.Data.(XML.Element)FIRSTCHILD;
 
 
ATTACH InputLocalEnvironment to OutputRoot.XML.Message.Data AS LASTCHILD;
 
 
You mean as above..?
 
Correct me IF I'm wrong, really I'm not able to put that statement correctly
 
 
Thanks Again! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | elvis_gn | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 11:09 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 08 Oct 2004 Posts: 1905 Location: Dubai 
  | 
		  
		    
			  
				Hi Kumar4,
 
 
I don't have the toolkit on my system, so I can't give you an accurate response, but I think the below should work
 
   
	| Code: | 
   
  
	CREATE LASTCHILD OF InputLocalEnvironment DOMAIN 'XMLNS' FROM InputRoot.XMLNS.Messages.Message1.Data.(XML.Element)*;
 
 
ATTACH InputLocalEnvironment to OutputRoot.XML.Message.Data AS LASTCHILD; | 
   
 
 
If it does not work, you can try to use 'TYPE 0x01000000' in a MOVE statement and then do the ATTACH.
 
 
Incase you are not getting around this, please paste a file trace of the LocalEnvironment taken after this ESQL processing, or if the code itself is throwing errors, then what the error is and on which line.
 
 
Regards. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 11:35 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				CREATE LASTCHILD OF InputLocalEnvironment DOMAIN 'XMLNS' FROM InputRoot.XMLNS.Messages.Message1.Data.(XML.Element)*; 
 
 
ATTACH InputLocalEnvironment to OutputRoot.XML.Message.Data AS LASTCHILD;
 
 
Above statement doesnt work, following is the error log
 
 
BIP2560E: 
 
A reference variable is required here. 
 
 
The statement or function requires a reference variable. The name given must therefore be the name of a declared reference variable and may not be extended (ie by a dot and another name) 
 
 
Correct the syntax of the expression and redeploy the message flow.
 
 
I even tried that with the following
 
 
CREATE LASTCHILD OF InputLocalEnvironment DOMAIN 'XMLNS' FROM InputRoot.XMLNS.Messages.Message1.Data;
 
 
Still errors out.
 
Please correct me
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 1:11 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				Can anybody reply to the above post please!!
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 1:27 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				Why do you want to modify InputLocalEnvironment which IIRC is as unmutable as InputRoot.  Just use Environment instead of InputLocalEnvironment ....
 
 
Enjoy    _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 1:55 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				thanks!
 
 
But I get the same error, when I do that.
 
If you can look into my previous posts, The LocalEnvironment was used to store the Input Message information and attach that to Output Message.
 
 
I was trying to grab a part of message from Input and assign that to Output which should be done dynamicaly.
 
 
I also pasted my sample Input and Output in the above post.
 
 
Do I need to configure this information in Compute Node properties for "Compute Mode" as Local Ennvironment and Message?
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | elvis_gn | 
		  
		    
			  
				 Posted: Tue Aug 21, 2007 9:39 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 08 Oct 2004 Posts: 1905 Location: Dubai 
  | 
		  
		    
			  
				Hi Kumar4,
 
   
	| Kumar4 wrote: | 
   
  
	ATTACH InputLocalEnvironment to OutputRoot.XML.Message.Data AS LASTCHILD;
 
 
Above statement doesnt work, following is the error log
 
 
BIP2560E: 
 
A reference variable is required here. 
 
 
The statement or function requires a reference variable. The name given must therefore be the name of a declared reference variable and may not be extended (ie by a dot and another name) | 
   
 
You cannot use a field in the ATTACH statement, it should be reference variable.
 
 
   
	| Code: | 
   
  
	CREATE LASTCHILD OF OutputLocalEnvironment DOMAIN 'XMLNS' FROM InputRoot.XMLNS.Messages.Message1.Data.(XML.Element)*;
 
      
 
DECLARE rToBeAttached REFERENCE TO OutputLocalEnvironment.*[<];
 
 
ATTACH rToBeAttached TO OutputRoot.XML.Message.Data AS LASTCHILD; | 
   
 
The above code deploys, but not sure if it works    (no time to test, sorry)
 
 
Set the compute node properties to 'Local Environment and Message' and take a file trace.
 
 
Regards. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Wed Aug 22, 2007 7:25 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				Thanks For the reply.
 
 
deployment worked, but at the runtime it complains of assigning field which already has a parent. I'm not able to understand the error.
 
 
Following is the log file:
 
10:12:26 test WebSphere Broker v6003[32683]: (WBRK6_DEFAULT_BROKER.Message_Exec_Group)[-1410204752]BIP2628E: Exc
 
eption condition detected on input node 'Message 1_to 2.MQInput'. : WBRK6_DEFAULT_BROKER.f7d1c783-1401-0000-0080-a
 
deba8e7c516: /build/S600_P/src/DataFlowEngine/ImbCommonInputNode.cpp: 1104: ImbCommonInputNode::run: ComIbmMQInputNode: Message_1_to_2_Msgflow#FCMComposite_1_9
 
 
 10:12:26 test WebSphere Broker v6003[32683]: (WBRK6_DEFAULT_BROKER.Message_Exec_Group)[-1410204752]BIP2230E: Err
 
or detected whilst processing a message in node 'Message 1_to 2.Compute'. : WBRK6_DEFAULT_BROKER.f7d1c783-1401-000
 
0-0080-adeba8e7c516: /build/S600_P/src/DataFlowEngine/ImbComputeNode.cpp: 464: ImbComputeNode::evaluate: ComIbmComputeNode: Message_1_to_2_Msgflow#FCMComposite_1_3
 
 
 10:12:26 test WebSphere Broker v6003[32683]: (WBRK6_DEFAULT_BROKER.Message_Exec_Group)[-1410204752]BIP2488E:  (.
 
Message 1_to 2_Compute.Main, 4.4) Error detected whilst executing the SQL statement 'CopyEntireMessage();'. : WBRK
 
6_DEFAULT_BROKER.f7d1c783-1401-0000-0080-adeba8e7c516: /build/S600_P/src/DataFlowEngine/ImbRdl/ImbRdlStatementGroup.cpp: 589:
 
SqlStatementGroup::execute: ComIbmComputeNode: Message 1_to 2#FCMComposite_1_3
 
 
 10:12:26 test WebSphere Broker v6003[32683]: (WBRK6_DEFAULT_BROKER.Message_Exec_Group)[-1410204752]BIP2934E: Err
 
or detected whilst executing the function or procedure 'CopyEntireMessage'. : WBRK6_DEFAULT_BROKER.f7d1c783-1401-0000-0080-ade
 
ba8e7c516: /build/S600_P/src/DataFlowEngine/ImbRdl/ImbRdlRoutine.cpp: 548: SqlRoutine::invoke: ComIbmComputeNode: Message_1_to_2_Msgflow#FCMComposite_1_3
 
 
 10:12:26 test WebSphere Broker v6003[32683]: (WBRK6_DEFAULT_BROKER.Message_Exec_Group)[-1410204752]BIP2488E:  (.
 
Message 1_to 2_Compute.CopyEntireMessage, 37.4) Error detected whilst executing the SQL statement 'ATTACH rToBeAtt
 
ached TO OutputRoot.XML.Message.Data;'. : WBRK6_DEFAULT_BROKER.f7d1c783-1401-0000-0080-adeba8e7c516: /build/S600_P/src/D
 
ataFlowEngine/ImbRdl/ImbRdlStatementGroup.cpp: 589: SqlStatementGroup::execute: ComIbmComputeNode: Message 1_to 2#
 
FCMComposite_1_3
 
 
 10:12:26 test WebSphere Broker v6003[32683]: (WBRK6_DEFAULT_BROKER.Message_Exec_Group)[-1410204752]BIP2332E: Err
 
or attaching field '(0x01000010):XMLNS' to field '(0x01000000):Data' which already has a parent. : WBRK6_DEFAULT_BROKER.f7d1c
 
783-1401-0000-0080-adeba8e7c516: /build/S600_P/src/DataFlowEngine/ImbParser.cpp: 1244: ImbSyntaxElement::attachAsLastChild: :
 
 
 
The message goes to Error queue which is connected to the failure terminal of MQInput
 
 
Please advise?
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Wed Aug 22, 2007 7:27 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				One more question:
 
 
Do the OutputRoot should start with the OutputRoot.XMLNS or XML?
 
 
AS the Input Domain is XMLNS, Does the output cares?
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Wed Aug 22, 2007 7:33 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| Kumar4 wrote: | 
   
  
	Do the OutputRoot should start with the OutputRoot.XMLNS or XML?
 
 | 
   
 
 
 
XML is depreciated in v6. Use XMLNS or XMLNSC. But it doesn't matter what the input is. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kumar4 | 
		  
		    
			  
				 Posted: Wed Aug 22, 2007 7:35 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 12 Aug 2007 Posts: 27
  
  | 
		  
		    
			  
				Thanks for that clarification
 
 
Could you please reply to above post (which has error log)
 
 
Thanks | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |