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 » Locate an Element in XML and Promote ESQL variable 2 SubFlow

Post new topic  Reply to topic
 Locate an Element in XML and Promote ESQL variable 2 SubFlow « View previous topic :: View next topic » 
Author Message
chibban
PostPosted: Sat Sep 24, 2005 2:29 pm    Post subject: Locate an Element in XML and Promote ESQL variable 2 SubFlow Reply with quote

Novice

Joined: 01 Jun 2005
Posts: 14

Hi all,
I have 2 problems and I'm in need for help :
1
==
I'm looking for a function that gets XML and an Element name,
locates that element in the XML and returns it's value.
I heard that it can be done in Java and XPath - so I can call it in my
ESQL code, and it can also be done using tree traversal in pure ESQL.
Can any one post a code sample or give a link to such ?
2
==
Is there a way to promote ESQL variables to a SubFlow properties ?
Somthing like :
Code:
 LogInDb(%%systemName%%, timestamp, %%status%%);
where the systemName and status are properties of the SubFlow ?
_________________
Thanks,
Sivan
Back to top
View user's profile Send private message
recallsunny
PostPosted: Sun Sep 25, 2005 6:03 am    Post subject: Reply with quote

Disciple

Joined: 15 Jun 2005
Posts: 163
Location: Massachusetts

use something like this for your Question 1:
Code:
Set tmpVar = THE( Select ITEM I.elevalue FROM Root.XML.yourmsg AS I WHERE I.elename = 'your element name here')

You could do also do this in Java/Xpath, however I donot think this simple task needs an external Java call (JVM call might have performance affect).

The answer to Question 2: Not in Version 5.0 of message broker. You cannot promote ESQL variables.
Back to top
View user's profile Send private message
jfluitsm
PostPosted: Sun Sep 25, 2005 10:07 pm    Post subject: Reply with quote

Disciple

Joined: 24 Feb 2002
Posts: 160
Location: The Netherlands

Question 2. This is announced for WMB v6.0
_________________
Jan Fluitsma

IBM Certified Solution Designer WebSphere MQ V6
IBM Certified Solution Developer WebSphere Message Broker V6
Back to top
View user's profile Send private message Send e-mail
chibban
PostPosted: Sun Oct 02, 2005 12:48 am    Post subject: Reply with quote

Novice

Joined: 01 Jun 2005
Posts: 14

Hey all !
First of all thanks for the fast reply.
Secondly, I tried using the select u mentioned but it doesn't work.
My XML tree looks like this :
Code:
Envelope
   Body
      InsertBug
         caseID
            type=number
            1111
         caseDesc
            type=char
            "this is my case"
...

How do I write SELECT to get the 1111?
Maybe somthing like :
Code:
DECLARE answer AS CHARACHTER;
SET answer = THE(SELECT ITEM I.??? FROM InputBody AS I
WHERE I.???);

I'll apricciate an answer with detailed example (including the XML tree) since I couldn't use the SELECT clause to get any data from XML...
_________________
Thanks,
Sivan
Back to top
View user's profile Send private message
JT
PostPosted: Sun Oct 02, 2005 8:56 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Your answer can be found here: http://publib.boulder.ibm.com/infocenter/wbihelp/topic/com.ibm.etools.mft.doc/ac17270_.htm

Although the SELECT function is capable of extracting XML attribute values, unless there's a compelling need to qualify the results using the WHERE clause, a more direct method is to simply use the SET statement.
Back to top
View user's profile Send private message
chibban
PostPosted: Sun Oct 02, 2005 1:19 pm    Post subject: Reply with quote

Novice

Joined: 01 Jun 2005
Posts: 14

I think that either I don't understand u or I wasn't clear about what I'm looking for.
I want to write a generic function, that recieve 2 arguments :
XML tree and element name
and retrieve the corelated element value.
For example, with the given XML I posted before and the name 'caseID'
this function should return the value '1111'.
the command :
Code:
SET answer = valueOfElement(InputRoot, 'caseID');

should SET answer to be '1111'.

The main thing is that I don't know where the elemend resides whithin the XML, I only get a name, and I need to search it and return it's value.
I succeeded doing so with ASBITSTREAM and POSITION (parsing the XML)
but I thoght there is a better way with the SELECT cluase.

Is there ?
_________________
Thanks,
Sivan
Back to top
View user's profile Send private message
vinbud117
PostPosted: Sun Oct 02, 2005 11:26 pm    Post subject: Reply with quote

Acolyte

Joined: 22 Jul 2005
Posts: 61

with respect to your second question.... You can set the values to Environment.Variables.xxx and then use these environment variables in the subflow.

Regarding the first question, i doubt if there is any command to search for an element...
Back to top
View user's profile Send private message
JT
PostPosted: Mon Oct 03, 2005 8:23 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Didn't mean to confuse you. What I intended for you to understand is that you could accomplish what you're looking for in either of two ways:

Quote:
DECLARE inputRootRef REFERENCE TO InputRoot.XML.Envelope.Body.InsertBug;
DECLARE answer CHARACTER;
CALL valueOfElement(inputRootRef, 'caseID', answer);


CREATE PROCEDURE valueOfElement(IN inputRootRef REFERENCE, IN tagName CHARACTER, OUT answer CHARACTER) BEGIN
SET answer = THE (SELECT ITEM I FROM inputRootRef.{tagName} AS I);
END;


or in a simpler fashion....

Quote:
DECLARE inputRootRef REFERENCE TO InputRoot.XML.Envelope.Body.InsertBug;
DECLARE answer CHARACTER;
CALL valueOfElement(inputRootRef, 'caseID', answer);


CREATE PROCEDURE valueOfElement(IN inputRootRef REFERENCE, IN tagName CHARACTER, OUT answer CHARACTER) BEGIN
SET answer = inputRootRef.{tagName};
END;
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Oct 03, 2005 8:26 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

{} only supports one level. It does not support, for example, A.B.C, just A.

One might be able to code a select statement, where the where clause used FIELDNAME.

Or one can write the standard loop over the children.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wschutz
PostPosted: Mon Oct 03, 2005 9:14 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

I've done this in broker V6 with a java compute node and xpath:
Code:

String s = inMsg.evaluateXpath("string(//item2find)");

will find "item2find" anywhere in the input tree. I haven't tried it
in broker v5.
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
jefflowrey
PostPosted: Mon Oct 03, 2005 9:22 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

evaluateXpath appears to only exist in the v6 API.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wschutz
PostPosted: Mon Oct 03, 2005 9:29 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Quote:
evaluateXpath appears to only exist in the v6 API.
Its a good thing I never tried it then
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
chibban
PostPosted: Sat Oct 15, 2005 8:58 am    Post subject: Reply with quote

Novice

Joined: 01 Jun 2005
Posts: 14

Finally I decided to search the XML as a string :
I used AsBitStream function to "flaten" the tree into string, and then used the POSITION function to locate the element inside that string. Then I parsed the part that I wanted (the value of the element).

I don't have V6, and I figured that parsing has better performance then :
1) External java call (to use XPATH).
2) Recursive tree traversal.

Thanks for the help !
_________________
Thanks,
Sivan
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 » Locate an Element in XML and Promote ESQL variable 2 SubFlow
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.