Author |
Message
|
hs |
Posted: Thu Jul 21, 2005 1:17 am Post subject: How to reorder the output message |
|
|
 Novice
Joined: 03 Jun 2005 Posts: 17
|
I would like to change the order of the fields when I produce the output message from the input.
I have an input message:
Code: |
<General>
<Messagetype>1 </Messagetype>
<Reference>
<Web>161565383 </Web>
<Request>0000 </Request>
</Reference>
<Date>00000 </Date>
</General> |
The output message should look like this:
Code: |
<General>
<Messagetype>1 </Messagetype>
<Reason>
<Status>0</Status>
</Reason>
<Reference>
<Web>161565383 </Web>
<Request>0000 </Request>
</Reference>
<Date>00000 </Date>
</General> |
However, when I create the output message:
Code: |
-- This needs to be done, as the input msg contains other fields,
-- which are not shown in this example...
SET OutputRoot = InputRoot;
SET OutputRoot.XML.General.Reason.Status='0';
|
ends up after :
<Date>0000</Date>
Can anyone suggest how I can put it in the correct order ? _________________ IBM Certified System Administrator - WebSphere MQ V5.3 |
|
Back to top |
|
 |
elvis_gn |
Posted: Thu Jul 21, 2005 2:05 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
If you want it to come before the reference you got to SET it before the reference.
In other words, dont use InputRoot = OutputRoot.... |
|
Back to top |
|
 |
mgk |
Posted: Thu Jul 21, 2005 2:13 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Look up the CREATE FIELD statement it gives you control over where elements are created.
Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
hs |
Posted: Thu Jul 21, 2005 3:52 am Post subject: |
|
|
 Novice
Joined: 03 Jun 2005 Posts: 17
|
I have managed to figure out how to reorder the output msg...
Code: |
[size=9]CREATE FIELD OutputRoot.XML.General;
CREATE FIRSTCHILD OF OutputRoot.XML.General NAME 'Messagetype' VALUE InputRoot.XML.General.Messagetype;
CREATE LASTCHILD OF OutputRoot.XML.General NAME 'Reason';
CREATE FIELD OutputRoot.XML.General.Reason.Status VALUE '0';
CREATE LASTCHILD OF OutputRoot.XML.General NAME 'Reference';
CREATE FIELD OutputRoot.XML.General.Reference.Web VALUE InputRoot.XML.General.Reference.Web;
CREATE FIELD OutputRoot.XML.General.Reference.Request VALUE InputRoot.XML.General.Reference.Request;
CREATE LASTCHILD OF OutputRoot.XML.General NAME 'Date' VALUE InputRoot.XML.General.Date;[/size] |
[/code]
Thanks for everyone's input. :  _________________ IBM Certified System Administrator - WebSphere MQ V5.3 |
|
Back to top |
|
 |
javaforvivek |
Posted: Fri Jul 22, 2005 2:50 am Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
hsalim,
Instead of creating all the elements once again for the output root, you can try this:
Code: |
SET OutputRoot = InputRoot;
CREATE LASTCHILD OF OutputRoot.XML.General NAME 'Reason';
CREATE FIELD OutputRoot.XML.General.Reason.Status VALUE '0';
DECLARE outputRef REFERENCE TO OutputRoot.XML.General.Reason;
DETACH outputRef;
ATTACH outputRef TO OutputRoot.XML.General.Messagetype AS NEXTSIBLING; |
mgk,
I think that this will give better performance than hsalim's code. What do you think? _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
hs |
Posted: Mon Jul 25, 2005 1:13 am Post subject: |
|
|
 Novice
Joined: 03 Jun 2005 Posts: 17
|
Thanks Vivek,
That worked !  _________________ IBM Certified System Administrator - WebSphere MQ V5.3 |
|
Back to top |
|
 |
|