Author |
Message
|
Girirsh K N |
Posted: Tue Apr 26, 2016 5:40 am Post subject: Xpath value retrieval |
|
|
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 |
|
 |
mqjeff |
Posted: Tue Apr 26, 2016 5:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
manoj5007 |
Posted: Tue Apr 26, 2016 8:23 am Post subject: |
|
|
 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 |
|
 |
mqjeff |
Posted: Tue Apr 26, 2016 8:29 am Post subject: |
|
|
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 |
|
 |
manoj5007 |
Posted: Tue Apr 26, 2016 9:01 am Post subject: |
|
|
 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 |
|
 |
Girirsh K N |
Posted: Tue Apr 26, 2016 9:26 pm Post subject: |
|
|
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 |
|
 |
smdavies99 |
Posted: Tue Apr 26, 2016 11:14 pm Post subject: |
|
|
 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 |
|
 |
maurito |
Posted: Tue Apr 26, 2016 11:39 pm Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
|
Back to top |
|
 |
Girirsh K N |
Posted: Wed Apr 27, 2016 2:14 am Post subject: |
|
|
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 |
|
 |
maurito |
Posted: Wed Apr 27, 2016 2:20 am Post subject: |
|
|
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 |
|
 |
smdavies99 |
Posted: Wed Apr 27, 2016 2:41 am Post subject: |
|
|
 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 |
|
 |
manoj5007 |
Posted: Wed Apr 27, 2016 7:44 am Post subject: |
|
|
 Acolyte
Joined: 15 May 2013 Posts: 64
|
|
Back to top |
|
 |
|