Author |
Message
|
shalabh1976 |
Posted: Fri Dec 16, 2005 12:51 am Post subject: XML help required |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
My input XML looks like:
<root>
<DataSet Name="SomeName">
<row/>
<row/>
<row/>
</DataSet>
<DataSet Name="AnotherName">
<row>
<row>
</DataSet>
</root>
I want the Cardinality of the row in DataSet whose name = "SomeName" ?
The following ESQL is not working:
SET Count = CARDINALITY(InputRoot.XML.root.DataSet.(XML.Attribute)"Name=AnotherName".row[])
Any ideas ? _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate
Last edited by shalabh1976 on Fri Dec 16, 2005 1:24 am; edited 1 time in total |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Dec 16, 2005 1:04 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
It should be
SET Count = CARDINALITY(InputRoot.XML.root.DataSet.Name(XML.Attribute)="AnotherName")
Check if it works
I have a doubt it will as we are using an = symbol. Maybe this
SET Count = CARDINALITY(InputRoot.XML.root.DataSet.'Name(XML.Attribute)="AnotherName"')
Why dont u try a SELECT WHERE if nothing works.
Regards. |
|
Back to top |
|
 |
shalabh1976 |
Posted: Fri Dec 16, 2005 1:28 am Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
Syntax Error in both cases.
Anyway I wanted the cardinality of the rows unders the DataSet. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Dec 16, 2005 1:47 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
You are allowed to do a WHERE on the statement, So do
DECLARE referenceDataSet REFERENCE TO InputRoot.XML.root.DataSet[] AS A WHERE A.Name(XML.Attribute) = "SomeName";
i'm not sure about the single quote or double quote, I haven't coded for 3 months
After that
SET Count = CARDINALITY(referenceDataSet.row);
I'm guessig that this willwork, if it dosen't try options....If it is atleast deployed and throws and error see the Event Log and tell us,
Regards. |
|
Back to top |
|
 |
shalabh1976 |
Posted: Fri Dec 16, 2005 2:37 am Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
Syntax error on the AS clause _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Dec 16, 2005 2:44 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
What do u mean by Syntax error ?
I typed the code in the toolkit and the code completion provided me with the AS clause.
Does your code fail to get deployed ?
OR
When you run the flow the flow fails at this line ?
Can you show us the "syntax error".
P.S: It could be becoz of the [] after DataSet, remove it and try also.
Regards. |
|
Back to top |
|
 |
shalabh1976 |
Posted: Fri Dec 16, 2005 3:26 am Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
I forgot to mention:
I am using V2.1 on Win2K.
Even after removing the [], the error remains. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
mgk |
Posted: Fri Dec 16, 2005 4:06 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
elvis_gn:
AS and WHERE clauses on a DECLARE statement are not allowed in ANY version of the broker. Either there is an error in your version of the toolkit, or you are getting mixed up with SELECT. Look up DECLARE in the manual/online-help.
shalabh1976:
On version 6 of Message Broker you could do a SELECT inside the CARDINALITY to do this, but on 2.1 I don't think that will work, and you will have to write a loop that counts the elements yourself.
Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
shalabh1976 |
Posted: Sun Dec 18, 2005 8:21 pm Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
Ok,
I only wanted to know the method to reference an XML tag which has the format:
<DataSet Name="Some Name" Type="Some Type"> so that I can distinguish it from the tag:
<DataSet Name="Some Name" Type="Another Type"> .
If I can reference them then I should be able to reference their children as well. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
elvis_gn |
Posted: Sun Dec 18, 2005 8:31 pm Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi shalabh1976,
Apart from the numerous DECLARE options (which I dont yet know are wrong, haven't tested) I mentioned the use of SELECT and mgk did too.
I am sure you could have got it right it you tired or searched this site.
Anyway,
Code: |
DECLARE referenceDataSet REFERENCE TO (SELECT A.DataSet FROM InputRoot.XML.root.DataSet AS A WHERE A.Name(XML.Attribute) = "SomeName");
|
We are here to mostly direct you in the right direction, dont expect perfect working code everytime.
Please try options on the code if it dosen't work, thats how u learn, not by asking questions
Regards. |
|
Back to top |
|
 |
|