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 » Xpath value retrieval

Post new topic  Reply to topic
 Xpath value retrieval « View previous topic :: View next topic » 
Author Message
Girirsh K N
PostPosted: Tue Apr 26, 2016 5:40 am    Post subject: Xpath value retrieval Reply with quote

Newbie

Joined: 26 Apr 2016
Posts: 6

Hi,

Iam retieving the Xpath from the database to the specific element and trying to fetch its value from the input.

XPATH-InputRoot.SOAP.*:Body.*:OperationName.*:Element(Present in the database)

I tried using below code but getting the null value.

DECLARE val CHARACTER '';
SET val=InputRoot.{XPATH};
--Tried this also
SET val=InputRoot.SOAP.{XPATH};

Please suggest how to retrieve the value from the input for the specific element of the XPATH.

Thanks in advance!
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Apr 26, 2016 5:50 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

It's great that you tried some things.

It doesn't look like you reviewed the documentation on using ESQL to select elements from the tree.

It also doesn't look like you reviewed the documentation on using XPath with ESQL or Broker in general.

You can't actually use XPath within ESQL, except using equivalent expressions.
http://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ak64800_.htm?lang=en

You can use Xpath from a Mapping node or from a JavaCompute node.
http://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ac30390_.htm%23ac30390_?lang=en

Also, as a side note. Esql does support {}, but only within a single tree level. So you can use InputRoot.{"abc"} to reference InputRoot.abc, but you can't use it to reference InputRoot.def.abc
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
manoj5007
PostPosted: Tue Apr 26, 2016 8:23 am    Post subject: Reply with quote

Acolyte

Joined: 15 May 2013
Posts: 64

And another point to be noted, there is no distinct SOAP parser but the SOAP messages are parsed by calling the XMLNSC parser, so the InputRoot.SOAP will itself stand invalid.

Apart from this, if you are storing the variable path in database, as per ESQL reference,i.e. Body.*:OperationName.*:Element, then the path to the variable should be built properly, for example for the below xml:

<soap:envelope xmlns="<soapenvelopens>">
<soap:header>
<soap:Body>
<Data>
<Name>xyz<Name>
<Data>
</soap:Body>
</soap:header>
</soap:envelope>

Suppose you want to retrieve the value of name, then you can store the below path in DB- *:envelope.*:Body.Data.Name,

And then retrieve the path from database eg. variable namepath

and then use InputRoot.{namepath}.

This should work
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Apr 26, 2016 8:29 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

manoj5007 wrote:
and then use InputRoot.{namepath}.

This should work


No. You can't use {namepath} to refer to more than one level of the message tree.

You can't use {<anything>} to refer to more than one level of the message tree.

InputRoot.{namepath} will look for an element at the root level named "a.b.c.d.e" instead of looking for InputRoot.a.b.c.d.e

A long time ago, I wrote a Java function that called evaluateXPath. It wasn't too hard.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
manoj5007
PostPosted: Tue Apr 26, 2016 9:01 am    Post subject: Reply with quote

Acolyte

Joined: 15 May 2013
Posts: 64

Thanks mqjeff.

Didn't really know that, then I believe EVAL should be the best way to go, again with manually concatenating the values though.

EVAL ('SET val = InputRoot.' ||namepath ||';');
Back to top
View user's profile Send private message
Girirsh K N
PostPosted: Tue Apr 26, 2016 9:26 pm    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2016
Posts: 6

Based on the delimiter . or / in the XPATh if I retrieve the level of elements present in it. Then i should be able to fetch the element value in the below showed manner

XPATH-InputRoot.*:Envelope.*:Body.*:OperationName.*:Element

ele1=InputRoot
ele2=*:Envelope
ele3=*:Body
ele4=*:OperationName
ele5=*:Element

SET val=InputRoot.{ele1}.{ele2}.{ele3}.{ele4}.{ele5}

OR

--Since InputRoot is mentioned
SET val=InputRoot.{ele2}.{ele3}.{ele4}.{ele5}


Is there anything wrong in the above statements because when i tried ,the val contains null than the value of an element.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Tue Apr 26, 2016 11:14 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Are you forgetting the PARSER when using InputRoot?

i.e. InputRoot.SOAP|XMLNSC|BLOB|Whatever

Using InputBody does not need the Parser to be mentioned.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
maurito
PostPosted: Tue Apr 26, 2016 11:39 pm    Post subject: Reply with quote

Partisan

Joined: 17 Apr 2014
Posts: 358

manoj5007 wrote:
so the InputRoot.SOAP will itself stand invalid.


This is incorrect.
See:
http://www.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ac64020_.htm?lang=en

It is perfectly valid to address fields using
Code:

InputRoot.SOAP.Body.soap:MessageRoot.etc
Back to top
View user's profile Send private message
Girirsh K N
PostPosted: Wed Apr 27, 2016 2:14 am    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2016
Posts: 6

Even When i use the parser iam getting the null

i.e InputRoot.SOAP.*:Body.*:OperationName.*:Element (Before removing the envelope)

ele1=InputRoot
ele2=SOAP
ele3=*:Body
ele4=*:OperationName
ele5=*:Element

SET val=InputRoot.{ele1}.{ele2}.{ele3}.{ele4}.{ele5}

OR

--Since InputRoot is mentioned
SET val=InputRoot.{ele2}.{ele3}.{ele4}.{ele5}
Back to top
View user's profile Send private message
maurito
PostPosted: Wed Apr 27, 2016 2:20 am    Post subject: Reply with quote

Partisan

Joined: 17 Apr 2014
Posts: 358

Girirsh K N wrote:
Even When i use the parser iam getting the null

i.e InputRoot.SOAP.*:Body.*:OperationName.*:Element (Before removing the envelope)

ele1=InputRoot
ele2=SOAP
ele3=*:Body
ele4=*:OperationName
ele5=*:Element

SET val=InputRoot.{ele1}.{ele2}.{ele3}.{ele4}.{ele5}

OR

--Since InputRoot is mentioned
SET val=InputRoot.{ele2}.{ele3}.{ele4}.{ele5}

Because the operation is NOT in the Body. Look at my previous post, there is a link to the SOAP message tree. You can work out which of the fields you want to get from there and code accordingly.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Apr 27, 2016 2:41 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

The use of usertrace could help here (disable the debugger)

When the set statement is processed, the trace output will tell you which element failed to get resolved.
Really helps finding where you are going wrong in a complex message tree.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
manoj5007
PostPosted: Wed Apr 27, 2016 7:44 am    Post subject: Reply with quote

Acolyte

Joined: 15 May 2013
Posts: 64

Thanks Maurito!!
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 » Xpath value retrieval
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.