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 - Conversion of simple type to attribute of complex?????

Post new topic  Reply to topic
 XML - Conversion of simple type to attribute of complex????? « View previous topic :: View next topic » 
Author Message
lanny boy
PostPosted: Tue May 18, 2004 1:00 am    Post subject: XML - Conversion of simple type to attribute of complex????? Reply with quote

Voyager

Joined: 24 Nov 2003
Posts: 79
Location: UK

I have an XML structure in the following format

InputRoot.XML.tagA.tagB.field1;
InputRoot.XML.tagA.tagB.field2;
InputRoot.XML.tagA.tagB.field3.... which repeats 100 times to;
....
InputRoot.XML.tagA.tagB.field100;

I need to change the format of the XML so that the simple type XML (above) is converted to an attribute of a new Complex type as below

OutputRoot.XML.tagC.(XML.attr)field1;
OutputRoot.XML.tagC.(XML.attr)field2;
....
OutputRoot.XML.tagC.(XML.attr)field100;

I have tried a number of things to work including the code below:

Set j = Cardinality(InputBody.SWIFT.Block4.*[]);
SET n = 1;

While n <= j do

Set OutputRoot.XML.tagC.(XML.attr)[n] = InputBody.tagA.tagB.[n];

SET n = n +1;
END WHILE;


When viewed in Debug mode the above code does seem to work initially in that the tags are changed and the data is mapped correctly, however upon writing to the output q it fails due to XML writing errors.


Is it possible that WMQSI does not allow dynamic conversion of a simple type and its value to an attribute of another complex type??


Thanks in advance
Lanny
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue May 18, 2004 2:02 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Is it possible that WMQSI does not allow dynamic conversion of a simple type and its value to an attribute of another complex type??

No - the MRM can certainly do this.
1. If you have not done so, create a message set and a message definition describing your input message.
2. Add an XML physical format to describe the input (identifier 'XML_in')
3. Add another XML physical format to describe the output (identifier 'XML_out')
4. In the XML_out properties of your simple elements, set the 'Render' property to 'XMLAttribute'.
5. Using a Compute node, or perhaps an RCD node, simple change the physical format of the message to 'XML_out'.
Back to top
View user's profile Send private message
lanny boy
PostPosted: Tue May 18, 2004 2:09 am    Post subject: Reply with quote

Voyager

Joined: 24 Nov 2003
Posts: 79
Location: UK

Thanks for that. I was also coming to the conclusion that I would have to create a new message set...


Out of curiosity is it possible to achieve the same thing within a compute node??
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue May 18, 2004 2:38 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I don't think you can change an element to an attribute without using MRM XML (i.e. you need to use a message set).
Back to top
View user's profile Send private message
fschofer
PostPosted: Tue May 18, 2004 3:15 am    Post subject: Reply with quote

Knight

Joined: 02 Jul 2001
Posts: 524
Location: Mainz, Germany

Hi
this worked for me, i do not know if its the best solution.

I added the IF statement because CARDINALITY also counts the empty
attributes of tagB and the fields

Code:
DECLARE j INTEGER;
DECLARE n INTEGER;
DECLARE z INTEGER;


SET j = CARDINALITY(InputRoot.XML.tagA.tagB.*[]);
SET n = 1;
SET z = 1;

WHILE n <= j DO

IF FIELDNAME(InputBody.tagA.tagB.*[n]) <> '' THEN
SET OutputRoot.XML.tagC.(XML.attr){FIELDNAME(InputBody.tagA.tagB.*[n])} VALUE = InputBody.tagA.tagB.*[n];
SET z = z + 1;
END IF;

SET n = n +1;
END WHILE;


Input:
Code:
<tagA>
<tagB>
<field001>data1</field001>
<field002>data2</field002>
<field003>data3</field003>
<field004>data4</field004>
<field005>data5</field005>
</tagB>
</tagA>


Output:
Code:
<tagC field001="data1" field002="data2" field003="data3" field004="data4" field005="data5"/>


Greetings
Frank
Back to top
View user's profile Send private message Send e-mail
lanny boy
PostPosted: Tue May 18, 2004 3:29 am    Post subject: Reply with quote

Voyager

Joined: 24 Nov 2003
Posts: 79
Location: UK

Thanks Frank that worked a treat!
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 - Conversion of simple type to attribute of complex?????
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.