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 » copying XML elements and associated attributes

Post new topic  Reply to topic
 copying XML elements and associated attributes « View previous topic :: View next topic » 
Author Message
JohnMetcalfe
PostPosted: Mon Feb 21, 2005 8:24 am    Post subject: copying XML elements and associated attributes Reply with quote

Apprentice

Joined: 02 Apr 2004
Posts: 40
Location: Edinburgh, Scotland

Does anyone know how to extract an element and associated attributes, but not pull over all the child elements as well

e.g given an input message such as this below:

<Message type="ILCMD" category="AuditMsgResend" >
<Cmd>
<Parameter name=’AUDIT_ID’>2345</ Parameter >
<Parameter name=’TARGETQ’>SLI.???????? </ Parameter >
/Cmd >
</Message>

I need to pull over the Message element and attributes to the Output, but not the child element and attributes.

I want a generic way of doing this, as the attribute set can vary across message types, so I don't want to have to hardcode the attribute names I'm looking for.

The output I'm looking to create is:

<Message type="ILCMD" category="AuditMsgResend">
.. other stuff in here....
</Message>

Thanks for any pearls of wisdom in advance!
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 21, 2005 8:26 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you only copy the message headers, and then write ESQL to copy the specific fields you want, and not copy the tree, then it will only copy what it tells you to.

If you need to refer to a field without using it's name, then you need to use an anonymous field reference. There is a section in the documentation on using anonymous field references in ESQL.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
JohnMetcalfe
PostPosted: Mon Feb 28, 2005 9:09 am    Post subject: Reply with quote

Apprentice

Joined: 02 Apr 2004
Posts: 40
Location: Edinburgh, Scotland

Thanks for your input Jeff,

I've finally solved the problem with the following code:

Code:
declare c integer;
set c = cardinality (InputRoot.XML.a.(XML.attr)*[]);
declare i integer;
set i = 1;
while i <= c do
        set OutputRoot.XML.a.(XML.attr)[i] = InputRoot.XML.a.(XML.attr)[i];
   set i = i + 1;
end while;


This copies an element and all its associated attributes, without knowing the names or number of attiributes beforehand, and it does NOT copy any child elements
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 » copying XML elements and associated attributes
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.