Author |
Message
|
sarathsps |
Posted: Fri May 23, 2014 7:22 am Post subject: Accessing Variables within {} in ESQL |
|
|
Novice
Joined: 04 May 2006 Posts: 19
|
I have a situation like this
declare TEMP CHAR '{ns3}:A.{ns3}:B';
declare a2 reference to InputRoot.XMLNSC.{ns2}:BCM.{ns3}:ChangeSegment.{TEMP};
when i have a variable value which contains {} it is not resolving the field.
I tried with
declare TEMP CHAR '"{ns3}:A.{ns3}:B"'; also and it is not working.
Is there any way we can resolve the field which inside the {}.
Thanks for your help. |
|
Back to top |
|
 |
McueMart |
Posted: Fri May 23, 2014 7:48 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Does
declare TEMP CHAR 'ns3:A.ns3:B';
declare a2 reference to InputRoot.XMLNSC.{ns2}:BCM.{ns3}:ChangeSegment.{TEMP};
work? Just a guess... |
|
Back to top |
|
 |
sarathsps |
Posted: Fri May 23, 2014 8:00 am Post subject: |
|
|
Novice
Joined: 04 May 2006 Posts: 19
|
declare TEMP CHAR 'ns3:A.ns3:B';
declare a2 reference to InputRoot.XMLNSC.{ns2}:BCM.{ns3}:ChangeSegment.{TEMP};
Thanks for your response.
I tried the above and it is not working. |
|
Back to top |
|
 |
McueMart |
Posted: Fri May 23, 2014 8:12 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
What are ns2 and ns3 defined as? Are they CHARACTER variables which will resolve to a NAMESPACE variable you have previously defined?
Paste in more of your code please  |
|
Back to top |
|
 |
sarathsps |
Posted: Fri May 23, 2014 8:19 am Post subject: |
|
|
Novice
Joined: 04 May 2006 Posts: 19
|
Thanks for your response... ns2 and ns3 are defined as namespaces.. Please see the below code.
DECLARE ns2 NAMESPACE 'http://abc.com/XXXX';
DECLARE ns3 NAMESPACE 'http://abc.com/XXXX/YYYY';
CREATE COMPUTE MODULE Test_Compute BEGIN
declare TEMP CHAR '{ns3}:A.{ns3}:B';
declare a2 reference to InputRoot.XMLNSC.{ns2}:BCM.{ns3}:ChangeSegment.{TEMP};
END; |
|
Back to top |
|
 |
McueMart |
Posted: Fri May 23, 2014 10:27 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Ok, when using a NAMESPACE, you dont need to surround it in { }.
So lets have another go:
declare TEMP CHAR 'ns3:A.ns3:B';
declare a2 reference to InputRoot.XMLNSC.ns2:BCM.ns3:ChangeSegment.{TEMP};
Although - now I remember back - I vaguely recall that using path evaluation using the { } syntax, has a limitation whereby it can only evaluate to 1 folder, not the multiple levels you have (e.g. A.B).
So can you also try this:
declare TEMP CHAR 'ns3:A';
declare TEMP2 CHAR 'ns3:B';
declare a2 reference to InputRoot.XMLNSC.ns2:BCM.ns3:ChangeSegment.{TEMP}.{TEMP2}; |
|
Back to top |
|
 |
sarathsps |
Posted: Fri May 23, 2014 12:23 pm Post subject: |
|
|
Novice
Joined: 04 May 2006 Posts: 19
|
McueMart wrote: |
So can you also try this:
declare TEMP CHAR 'ns3:A';
declare TEMP2 CHAR 'ns3:B';
declare a2 reference to InputRoot.XMLNSC.ns2:BCM.ns3:ChangeSegment.{TEMP}.{TEMP2}; |
I tried above and not working  |
|
Back to top |
|
 |
McueMart |
Posted: Fri May 23, 2014 1:29 pm Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Ok the next I would try is something like:
declare TEMPNS CHAR 'ns3';
declare TEMP1 CHAR 'A';
declare TEMP2 CHAR 'B';
declare a2 reference to InputRoot.XMLNSC.ns2:BCM.ns3:ChangeSegment.{TEMPNS}:{TEMP1}.{TEMPNS}:{TEMP2};
As im not sure if the path substitution can replace the Namespace and field name in one go. If this doesn't work - im all out of ideas! Someone who knows the answer will be along shortly im sure  |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri May 23, 2014 10:29 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
McueMart is right. The other possibility you have would be to use evaluate... but that would be a lot slower...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 26, 2014 1:37 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
My first programming mentor told me something very useful.
"If the problem seems too hard then try solving a different problem"
In this case, the problem is to end up with a REFERENCE variable 'a2' that points to *.ns3:A.ns3:B where * is an unknown ESQL field reference. You are trying very hard ( impressively hard ) to solve it using ESQL's path reference syntax + string manipulation. But it would be very easy to write an ESQL procedure that takes an ESQL REFERENCE variable 'a' and moves it to 'a2'. Is there some reason why that's not an acceptable solution? _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
sarathsps |
Posted: Tue May 27, 2014 9:33 am Post subject: |
|
|
Novice
Joined: 04 May 2006 Posts: 19
|
fjb_saper wrote: |
McueMart is right. The other possibility you have would be to use evaluate... but that would be a lot slower...
Have fun  |
I tried using the EVAL function in MB7 like below and it is not resolving the reference path..
declare TEMP CHAR 'ns3:A.ns3:B';
declare a2 reference to InputRoot.XMLNSC.ns2:BCM.ns3:ChangeSegment;
set a2=a2.EVAL(TEMP); |
|
Back to top |
|
 |
sarathsps |
Posted: Tue May 27, 2014 9:35 am Post subject: |
|
|
Novice
Joined: 04 May 2006 Posts: 19
|
kimbert wrote: |
My first programming mentor told me something very useful.
"If the problem seems too hard then try solving a different problem"
In this case, the problem is to end up with a REFERENCE variable 'a2' that points to *.ns3:A.ns3:B where * is an unknown ESQL field reference. You are trying very hard ( impressively hard ) to solve it using ESQL's path reference syntax + string manipulation. But it would be very easy to write an ESQL procedure that takes an ESQL REFERENCE variable 'a' and moves it to 'a2'. Is there some reason why that's not an acceptable solution? |
Hi Kimbert,
Thanks for your reply. I am not able to use the MOVE the another portion of the reference variable is still a char. The below one is not working.
DECLARE A3 REFERENCE TO InputRoot.XMLNSC.ns2:BCM.ns3:ChangeSegment;
set TEMP = 'ns2:PROVIDER.ns2:PROVIDER_SERVICE_LOCATION';
move A3 to A3.{TEMP}; |
|
Back to top |
|
 |
mqjeff |
Posted: Tue May 27, 2014 9:44 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You can't use {} for more than one level i.e. A.B.C, you have to use A.{B}.{C}, not A.{B.C}.
It doesn't work.
You shouldn't be using {}.
You should be using MOVE FIRST CHILD |
|
Back to top |
|
 |
Esa |
Posted: Tue May 27, 2014 11:04 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
sarathsps wrote: |
I am not able to use the MOVE the another portion of the reference variable is still a char |
Read this
Code: |
DECLARE A3 REFERENCE TO InputRoot.XMLNSC.ns2:BCM.ns3:ChangeSegment;
DECLARE MyProvider CHAR 'PROVIDER'
MOVE A3 FIRSTCHILD NAMESPACE ns2 NAME MyProvider;
--MOVE again
|
|
|
Back to top |
|
 |
|