ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » xml to mrm

Post new topic  Reply to topic
 xml to mrm « View previous topic :: View next topic » 
Author Message
ANorm
PostPosted: Thu May 15, 2003 4:57 pm    Post subject: xml to mrm Reply with quote

Newbie

Joined: 15 May 2003
Posts: 7

I need to map xml to mrm fields. However I have problem with repeating field.

Input is xml, need to output to fixed length

The input xml repeating could have one or more but will have a tag to indicate the number of repeats

Input Message

<Input>
<FieldA>abc</FieldA>
<FieldB>DDDD</FieldB>
<Count>3</Count>
<Repeat>
<R1>mmmm</R1>
<R2>nnnn</R2>
</Repeat>
<Repeat>
<R1>pppp</R1>
<R2>* please do not use *</R2>
</Repeat>
<Repeat>
<R1>yyyy</R1>
<R2>zzzz</R2>
</Repeat>
</Input>


Output Message should be:
* please do not use *

Have build a message set with MRM fixed length
such as follows:
FieldA (fixed length3)
FieldB (fixed length4)
Count (integer)
Repeat Type (repeating = yes, value of = Count)
R1 (fixed length4)
R2 (fixed length4)


Have error (element R1 not found) whenever the Count is greater than 1. Any suggestion/advise?

Thanks.
Back to top
View user's profile Send private message
EgilsJ.Rubenis
PostPosted: Thu May 15, 2003 11:33 pm    Post subject: Reply with quote

Acolyte

Joined: 18 Nov 2002
Posts: 63
Location: Germany, Alfeld

Hi,

your index must show to the element 'Repeat'

Set OutputRoot..... = InputRoot...."Repeat"[Index]."R1".


It is not wroking propperly if the index shows to R1 like tihs

Set OutputRoot..... = InputRoot...."Repeat"."R1"[Index].
Back to top
View user's profile Send private message Send e-mail
ANorm
PostPosted: Mon May 19, 2003 5:38 pm    Post subject: Reply with quote

Newbie

Joined: 15 May 2003
Posts: 7

Hi Egils,

Thanks for the reply. Could you please explain the [index].
Back to top
View user's profile Send private message
EgilsJ.Rubenis
PostPosted: Mon May 19, 2003 10:30 pm    Post subject: Index in XML structure Reply with quote

Acolyte

Joined: 18 Nov 2002
Posts: 63
Location: Germany, Alfeld

Hi,

sorry for the delay. Here is ther explanation.

If you have an incoming XML File (as yours) you need to get the occurence of the Elements. You don't need to have a tag to indicate the number of repeats. The statement "Cardinality" computes for you
how much Elements you have in your XML named "REPEAT".

In your case INDEX-B will be three

Example:

DECLARE INDEX_A INTEGER;
DECLARE INDEX_B INTEGER;

SET INDEX_B = CARDINALITY("InputBody"."REPEAT" );
SET INDEX_A = 1;

WHILE INDEX_A <= INDEX_B DO

SET "OutputRoot"."MRM"."R1" = "InputBody"."REPEAT"[INDEX_A].R1;
SET "OutputRoot"."MRM"."R2" = "InputBody"."REPEAT"[INDEX_A].R2;

SET INDEX_A = INDEX_A +1;

END WHILE;

I hope it helps you.

Egils
Back to top
View user's profile Send private message Send e-mail
EgilsJ.Rubenis
PostPosted: Mon May 19, 2003 11:52 pm    Post subject: missed a little detail Reply with quote

Acolyte

Joined: 18 Nov 2002
Posts: 63
Location: Germany, Alfeld

Hi,

sorry i missed a little detail

SET INDEX_B = CARDINALITY("InputBody"."REPEAT" []);

at the end of the statement you need [].

Egils
Back to top
View user's profile Send private message Send e-mail
ANorm
PostPosted: Thu May 22, 2003 1:02 am    Post subject: Reply with quote

Newbie

Joined: 15 May 2003
Posts: 7

Thanks for the reply.

In this situation the number of repeat is a variable as indicated by
the value of <Count> tag. For this particular message(as shown in my orignal posting), count=3.
It could be some other integer for another input message.

Below is the code:

DECLARE INDEX_A INTEGER;
DECLARE Count INTEGER;


SET INDEX_A = 1;

WHILE INDEX_A <= Count DO



SET "OutputRoot"."MRM"."Repeat"."R1" = "InputBody"."REPEAT"[INDEX_A].R1;
SET "OutputRoot"."MRM"."R2" = "InputBody"."REPEAT"[INDEX_A].R2;

SET INDEX_A = INDEX_A +1;

END WHILE;


I still have "element R1 not found" if the count is greater than 1.

Any idea of how to make use of the number of count for mapping?
Back to top
View user's profile Send private message
Craig B
PostPosted: Wed Jun 18, 2003 1:30 am    Post subject: Reply with quote

Partisan

Joined: 18 Jun 2003
Posts: 316
Location: UK

From the description given it would seem that the MRM-CWF layer has been set up such that there is Repeating parent called "Repeat" which has been set to repeating and based on the value of the integer field Count. This repeating parent contains two children called R1 and R2. If you are mapping fields from the sample XML input message then the following should set up the output message tree for the repeating section :

Code:

SET OutputRoot.MRM.Count = CARDINALITY(InputBody.Input.Repeat[]);
DECLARE recCount INT;
SET recCount = 0;
WHILE recCount < OutputRoot.MRM.Count DO
  SET recCount = recCount + 1;
  SET OutputRoot.MRM.Repeat[recCount].R1 = InputBody.Input.Repeat[recCount].R1;
  SET OutputRoot.MRM.Repeat[recCount].R2 = InputBody.Input.Repeat[recCount].R2;
END WHILE;


Since the XML and MRM-CWF repeating structures have the same fields, ie they both have R1 and R2, then this ESQL can be simplified to the following as long as the input message is guaranted to have R1 and R2 in the same order :

Code:

SET OutputRoot.MRM.Count = CARDINALITY(InputBody.Input.Repeat[]);
DECLARE recCount INT;
SET recCount = 0;
WHILE recCount < OutputRoot.MRM.Count DO
  SET recCount = recCount + 1;
  SET OutputRoot.MRM.Repeat[recCount] = InputBody.Input.Repeat[recCount];
END WHILE;


However, a better approach may be to set up an MRM-XML physical format layer in the same messageSet such that the logical model is the same for both the input and output messages. It would seem that both have the same structure at the logical level and so this should be possible in this case. If this could be done, then the mapping to product the MRM_CWF output message could just be done with the following ESQL :

Code:

SET OutputRoot = InputRoot;
SET OutputRoot.Properties.MessageFormat = 'CWF';


I hope this helps.
_________________
Regards
Craig
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » xml to mrm
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.