| Author | 
		  Message
		 | 
		
		  | szab | 
		  
		    
			  
				 Posted: Fri May 02, 2008 1:51 am    Post subject: xml to MRM convert using element mapping | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 01 May 2008 Posts: 14
  
  | 
		  
		    
			  
				hi,
 
 
I am a beginner, so please give me some advice how should I do the next mapping in ESQL.
 
I've got 2 message definitions: A.mxsd and B.mxsd.
 
I'd l ike to convert the inbound XML message to an MRM outbound message using a Compute node.
 
How can I map the elements of the inbound XML to the elements of the outbound MRM in ESQL ?
 
Is this ESQL code correct?
 
SET OutputRoot.MRM.B_Customer = InputRoot.XMLNS.Customer;
 
 
How should I set the message Format, Header to the outbound MRM?
 
how should I start the mapping from XML to MRM in ESQL?
 
 
The mapping should be:
 
Inbound XML                                Outbound MRM
 
A.mxsd        ----mapping----           B.mxsd
 
Customer                                      B_Customer
 
CustomerDetails                            B_CustomD
 
Accounts                                       B_Accs
 
Account                                        B_Acc
 
Name                                           B_Name 
 
Birth                                             B_Birth
 
AccountNumber                             B_AccN
 
AccountType                                 B_AccT
 
Ba                                                B_Ba | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Fri May 02, 2008 1:58 am    Post subject: Re: xml to MRM convert using element mapping | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| szab wrote: | 
   
  
	| I am a beginner, so please give me some advice how should I do the next mapping in ESQL. | 
   
 
 
 
By telling your budget holder it's unreasonable to expect you to do this untrained?
 
 
   
	| szab wrote: | 
   
  
	| I've got 2 message definitions: A.mxsd and B.mxsd. | 
   
 
 
 
If A is the inbound message & B is the outbound message, don't use the XMLNS domain, use MRM for both.
 
 
If these are 2 separate output formats from a single input, you'll need to build 2 trees and PROPOGATE. As a beginner, you may find it clearer to use 2 compute nodes.
 
 
   
	| szab wrote: | 
   
  
	Is this ESQL code correct?
 
SET OutputRoot.MRM.B_Customer = InputRoot.XMLNS.Customer;
 
 | 
   
 
 
 
Only if all the names match up. It's certainly not self documenting.
 
 
   
	| szab wrote: | 
   
  
	
 
How should I set the message Format, Header to the outbound MRM?
 
 | 
   
 
 
 
With SET statements.
 
 
   
	| szab wrote: | 
   
  
	
 
how should I start the mapping from XML to MRM in ESQL?
 
 | 
   
 
 
 
With SET statements
 
 
If you have both input and output messages in message sets, consider the Mapping node. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | szab | 
		  
		    
			  
				 Posted: Fri May 02, 2008 2:05 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 01 May 2008 Posts: 14
  
  | 
		  
		    
			  
				thx for your quick answers, but i have to do the mapping in ESQL...
 
Any advice how and where to start ? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | szab | 
		  
		    
			  
				 Posted: Fri May 02, 2008 2:10 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 01 May 2008 Posts: 14
  
  | 
		  
		    
			  
				The mapping should be:
 
A.mxsd                ---- mapping----           B.mxsd
 
Customer             ----mapping----                          B_Customer
 
CustomerDetails ----mapping----                            B_CustomD
 
Accounts ----mapping----                                       B_Accs
 
Account  ----mapping----                                       B_Acc
 
Name    ----mapping----                                        B_Name 
 
Birth   ----mapping----                                           B_Birth
 
AccountNumber        ----mapping----                      B_AccN
 
AccountType    ----mapping----                              B_AccT
 
Ba                    ----mapping----                             B_Ba
 
 
my incoming xml message looks like: 
 
 
   
	| Code: | 
   
  
	<?xml version="1.0"?>
 
<Customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///c:/.../probBack1.xsd">
 
    <CustomerDetails>
 
        <Name>jdr</Name>
 
        <Birth>NMTOKEN</Birth>
 
    </CustomerDetails>
 
    <Accounts>
 
        <Account>
 
            <AccountNumber>haha</AccountNumber>
 
            <AccountType>hehe</AccountType>
 
            <Ba>1.23</Ba>
 
        </Account>
 
        <Account>
 
            <AccountNumber>ger</AccountNumber>
 
            <AccountType>geje</AccountType>
 
            <Ba>1.23</Ba>
 
        </Account>
 
        <Account>
 
            <AccountNumber>jsjv</AccountNumber>
 
            <AccountType>jsc</AccountType>
 
            <Ba>1.23</Ba>
 
        </Account>
 
    </Accounts>
 
</Customer> | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Fri May 02, 2008 2:20 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| szab wrote: | 
   
  
	| Any advice how and where to start ? | 
   
 
 
 
With your budget holder. WMB is a complex product and proper training is essential. This forum is a good technical resource, but a bad training medium.
 
 
It's still unclear if your A.msxd defines the input message, but assuming it does (which seems to be what you're implying) then it's a straightforward mapping exercise. You don't indicate any transformation & the most complex part of your structure is the repeating <Account> tag.
 
 
My advice: read the ESQL manual, look at the provided samples, set up a Compute node and observe the results with the debugger and/or some trace. In the absense of formal training (which I still strongly recommend) experiementation is your best tutor.
 
 
      _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Fri May 02, 2008 4:13 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	Is this ESQL code correct?
 
SET OutputRoot.MRM.B_Customer = InputRoot.XMLNS.Customer;
 
 | 
   
 
You should use XMLNSC in new message flows, not XMLNS. Especially if the message flow is also using the MRM domain.
 
 
I hope B_Customer is not the root element of the output message. The MRM domain is different from the others, in that the root element is represented by the 'MRM' node itself. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | szab | 
		  
		    
			  
				 Posted: Fri May 02, 2008 5:00 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 01 May 2008 Posts: 14
  
  | 
		  
		    
			  
				Sadly, B_Customer is the rootElement...   | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Fri May 02, 2008 5:27 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				Don't be too sad. This should be correct:
   
	| Code: | 
   
  
	| SET OutputRoot.MRM = InputRoot.XMLNSC.Customer;  | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | szab | 
		  
		    
			  
				 Posted: Fri May 02, 2008 5:38 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 01 May 2008 Posts: 14
  
  | 
		  
		    
			  
				thx a lot, I thought the same    | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | szab | 
		  
		    
			  
				 Posted: Sat May 03, 2008 6:05 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 01 May 2008 Posts: 14
  
  | 
		  
		    
			  
				another question but the same XML message mapping,formatting that i posted before:
 
The incoming XML consists of 3 Account elements but the output MRM message has only 1 Account element with a restriction. If the AccountType element has 'hehe' value from the 3 Account elements in the incoming XML, then only the B_AccT element should be set in the output MRM message.
 
How can I achieve this criteria in ESQL?
 
I tried to code something similar but it didn't work ...
 
anyone help?
 
 
   
	| Code: | 
   
  
	DECLARE accRef REFERENCE TO InputRoot.XMLNSC.Customer.Accounts;
 
      
 
      DECLARE I INTEGER 1 ;      
 
      SET I = 1;
 
      WHILE (I <= CARDINALITY(accRef.*[])) DO
 
         IF(accRef.Account[I].AccountType = hehe) THEN
 
         SET OutputRoot.MRM.B_Accs.B_Acc.B_AccT = accRef.Account[I].AccountType;
 
      
 
         SET I = I + 1;
 
         END IF;END WHILE; | 
   
 
[/code] | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | n1ghtrain | 
		  
		    
			  
				 Posted: Sat May 03, 2008 10:59 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Apprentice
 
 Joined: 23 Mar 2006 Posts: 48 Location: Bangalore 
  | 
		  
		    
			  
				maybe you should try 'hehe' instead of hehe
 
and OutputRoot.MRM.B_Accs.B_Acc[I].B_AccT | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Sun May 04, 2008 11:53 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	maybe you should try 'hehe' instead of hehe
 
and OutputRoot.MRM.B_Accs.B_Acc[I].B_AccT | 
   
 
I don't think that's the requirement. 
   
	| Quote: | 
   
  
	| only the B_AccT element should be set in the output MRM message | 
   
 
So there's only on B_AccT element, and it does not need a subscript.
 
 
szab: If my comment above is correct then you can exit the loop after finding a match. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | szab | 
		  
		    
			  
				 Posted: Thu May 08, 2008 4:33 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 01 May 2008 Posts: 14
  
  | 
		  
		    
			  
				Hi again!
 
Could anyone tell me why not creates this code the output MRM tree?
 
I've checked every possible failure(project references, messageDefinition,  MessageType,Set,Format in ESQL, and so on) but I've only got the red line as output MRM tree. Did I use the references correctly? or why is this happening?
 
 
 
   
	| Code: | 
   
  
	   DECLARE CustomRef REFERENCE TO InputRoot.MRM;
 
      
 
   WHILE LASTMOVE(CustomRef) DO
 
      DECLARE genCustomRef REFERENCE TO CustomRef.GenericCustomer;
 
      DECLARE outref REFERENCE TO OutputRoot.MRM;
 
   
 
      WHILE LASTMOVE(genCustomRef) DO
 
         [color=red]SET outref.B2_GenCustom.antx_id = InputRoot.MRM.Customer.CustomerId ;[/color]
 
         SET outref.B2_GenCustom.Antx_name = genCustomRef.FullName;
 
         SET outref.B2_GenCustom.Antx_persid = genCustomRef.PersonalID;
 
         SET outref.B2_GenCustom.Antxcounterpart = genCustomRef.BasicNumber ;
 
         SET outref.B2_GenCustom.Isresident = genCustomRef.DeviseNative ;
 
         SET outref.B2_GenCustom.Antx_classes_id = genCustomRef.Type ;
 
         MOVE genCustomRef NEXTSIBLING;
 
      END WHILE; | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |