|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
defaults for missing XML fields |
« View previous topic :: View next topic » |
Author |
Message
|
devita |
Posted: Fri Jul 20, 2001 8:30 am Post subject: |
|
|
Novice
Joined: 19 Jul 2001 Posts: 14
|
I'd like to build a generic compute node that transforms a XML message in a MRM message but I have to handle also the missing fields in the XML structure.
By example, I have the Cobol structure:
01 EMP
02 EMPSURNAME char(0
02 EMPFIRSTNAME char(0
02 EMPCODE char(05)
I import this structure in the repository and generate a MRM message with id=DLS9TFG070001.
If I receive a message with a XML format:
<EMP>
<EMPSURNAME>DEVITA</EMPSURNAME>
<EMPFIRSTNAME>UGO</EMPFIRSTNAME>
<EMPID>24113</EMPID>
</EMP>
now I use this ESQL code (or similar):
SET OutputRoot.Properties.MessageSet = 'DLS9TFG070001';
SET OutputRoot.Properties.MessageType = 'Emp';
SET OutputRoot.Properties.MessageFormat = 'CWF';
SET OutputRoot.MRM = InputBody.EMP;
(in a generic compute node these values are picked in a database)
and so I have this message:DEVITA UGO 24113. So all works fine!!!
If I receive a message with this contents
<EMP>
<EMPSURNAME>DEVITA</EMPSURNAME>
<EMPID>24113</EMPID>
</EMP>
the same ESQL code produces this output: DEVITA 24113 without the FIRSTNAME field, when I'd like to produce the message: DEVITA 24113, with the field FIRSTNAME padded to blanks.
My questions are:
1) If I known the target MRM format, is it possible to compare the MRM with the input XML?
2) How can I known, in a generic compute node, the required MRM fields for test the null condition in the XML message for padding the missing fields to blanks?
3) Could I use some API for query the message dictionary?
Thank you for your help
[ This Message was edited by: devita on 2001-07-20 09:36 ] |
|
Back to top |
|
 |
wolstek |
Posted: Thu Aug 30, 2001 7:38 am Post subject: |
|
|
Acolyte
Joined: 25 Jun 2001 Posts: 52 Location: Bristol, UK
|
If the assumption is
1. the XML tags are the same as the MRM fields
2. there is only one level of XML tag nesting
the following eSQL could be used to copy data from the input XML to the MRM
DECLARE N INTEGER;
DECLARE I INTEGER;
-- set message domain, type etc.
SET I = 1;
SET N = CARDINALITY(InputRoot.XML.*[1].*[]);
WHILE I <= N DO
EVAL ('SET OutputRoot.MRM.'
|| FIELDNAME(InputRoot.XML.*[1].*[I])
|| ' = InputRoot.XML.*[1].*[I];');
SET I = I + 1;
END WHILE;
If you have more nested levels then it can be done but more complex and maybe with EVAL():
On a more difficult note is the setting of the default values for the MRM fields for which an input XML tag is not specified.
A technique I developed was to specify a BLOB string containing default values for the whole MRM structure and load this into the reference database table which also holds ther message set/type etc, which you alluded to.
Then having saved your XML input to a safe place , some scratchpad area which will not get lost, copy this default BLOB into OutputRoot."BLOB"."BLOB", then set the message set/type , then push through a Reset Content Descriptor Node which parses to MRM. Then the BLOB will be converted to the MRM with default values in place.
After that copy the input XML, from your safe store using eSQL above.
It actually turned out that this was more efficient than lots of SET OutputRoot.MRM.fieldname = value especially of lots of fields and also avoided hardcoding of field names |
|
Back to top |
|
 |
chrisfra |
Posted: Fri Aug 31, 2001 9:59 am Post subject: |
|
|
Novice
Joined: 24 Jun 2001 Posts: 14
|
You can use the eSQL function COALESCE to provide a default value for the value of a field which might not exist in a message. For example, the expression:
COALESCE(Body.EMPFIRSTNAME,'?')
would return the value of the EMPFIRSTNAME field in the message if it existed, or '?' if that field did not exist. You could, or course, use any default value you choose in place of the '?'.
Hope this helps. |
|
Back to top |
|
 |
devita |
Posted: Wed Sep 12, 2001 6:41 am Post subject: |
|
|
Novice
Joined: 19 Jul 2001 Posts: 14
|
Thanks for your suggestions; the eSQL sugggested by Wolstek is a good tip but give me an hard problem:
Wolstek says "set the message set/type, then push through a RCD".
Is it possible to set message set/type in a compute node?
Is it possible to build a generic RCD and generic flow or I must have a RCD node for every MRM structure?
thank you
[ This Message was edited by: devita on 2001-09-12 07:54 ] |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|