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 » Referencing XML Attributes

Post new topic  Reply to topic
 Referencing XML Attributes « View previous topic :: View next topic » 
Author Message
duffMan
PostPosted: Wed Oct 08, 2003 6:52 pm    Post subject: Referencing XML Attributes Reply with quote

Voyager

Joined: 03 Jun 2002
Posts: 75

Hi,

I am trying to "efficiently" reference an XML tree that may look something like:

Code:
<XMLRoot>
       <InputFields>
               <abc zzz="A">value1</abc>
               <abc zzz="B">value2</abc>
               <abc zzz="C">value3</abc>
                ...
       </InputFields>
</XMLRoot>


- as you can see the aggregate "InputFields" contains only one child element, namely "abc" which repeats, and abc contains an xml attribute zzz which contains some data (which happens to be unique accross all zzz attributes on abc)

As an example,
I need to extract the value contained in element "abc" where "zzz"="C".

I don't want to scan because in the real-life example there will be hundreds of "abc" siblings for which I need to reference many times over.

I don't want to use an index such as SET myValue=abc[3], because abc[3] may not actually be zzz="C", should zzz="A" or zzz="B" not exist in a particular instance of the XML.


So I get back to the question: how do I effeciently, if at all possible, reference an XML element by the value of one of it's attributes?

Thanks for any ideas.
Back to top
View user's profile Send private message
kirani
PostPosted: Wed Oct 08, 2003 7:04 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Well, I can think of these options,
a) scan the tree for required element and attribute.
b) use SELECT statement to select value from the XML tree.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
duffMan
PostPosted: Wed Oct 08, 2003 7:22 pm    Post subject: Reply with quote

Voyager

Joined: 03 Jun 2002
Posts: 75

You woudn't mind showing such as XML statement with an XML attribute in the where clause?

I am also assuming that a SELECT statement will result in a scan internally at run-time, but it would look much cleaner code-wise.

Thanks.
Back to top
View user's profile Send private message
kirani
PostPosted: Wed Oct 08, 2003 11:03 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

That's correct, using SELECT statement will also internally scan the elements. Here is the sample code,
Code:

SET Val = THE ( SELECT ITEM T from InputRoot.XML.XMLRoot.InputFields.abc[] as T WHERE T.(XML.Attribute)zzz = 'C')

_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kimbert
PostPosted: Thu Oct 09, 2003 1:07 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I assume you are using the XML domain?
In the MRM domain, this style of XML is known as 'XMLElementAttrId'.
(which means that the elements are identified by one of their attributes, instead of by their tag name)
If you modelled your message using this XML rendering style for the 'InputFields' element, you would be able to create a much simpler message tree.

InputBody
InputFields
A
B
C

Then you would be able to write ESQL like this:

SET Val = InputBody.InputFields.C

Using the MRM domain generally results in simpler message trees, and therefore simpler ESQL. Message processing is a little slower, though.

Let me know if you're interested.
Back to top
View user's profile Send private message
duffMan
PostPosted: Thu Oct 09, 2003 4:02 am    Post subject: Reply with quote

Voyager

Joined: 03 Jun 2002
Posts: 75

Thanks Kirani for the SQL...I'll see how it performs.

Thanks kimbert, I'll give that a try too. I do have a DTD for that XML which I'll attempt to import into MRM.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Oct 10, 2003 12:54 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

To avoid any confusion...importing the DTD will not automatically set up your MRM message set in the way I described - it should be a good start, though, because it will create all your elements and organise them into the right structure.
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 » Referencing XML 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.