Author |
Message
|
Fuzzy_mq |
Posted: Fri Oct 15, 2004 3:01 am Post subject: How to get count of repeating elements using ESQL?? |
|
|
Apprentice
Joined: 27 May 2004 Posts: 31 Location: US
|
Hi Folks,
I am having XML as input Message.
e.g
<Customer>
<Name>Ivin</Name>
<OrderNum>2346</OrderNum>
<ItemDetails Item="Chocs" Qty="20">
<ItemDetails Item="Cookies" Qty="15">
<ItemDetails Item="Bud" Qty="5">
</Customer>
Now I want count of ItemDetails in ESQL. How do I get that? I am trying to use cardinality but for some reason its not working.
Regards,
Suchit |
|
Back to top |
|
 |
aq |
Posted: Fri Oct 15, 2004 4:59 am Post subject: |
|
|
Apprentice
Joined: 20 Dec 2001 Posts: 47
|
Hi
Is the sample XML in your post exatcly same that you are using ? I think it's not valid XML (end-tag's of ItemDetails elements are missing).
<Customer>
<Name>Ivin</Name>
<OrderNum>2346</OrderNum>
<ItemDetails Item="Chocs" Qty="20"/>
<ItemDetails Item="Cookies" Qty="15"/>
<ItemDetails Item="Bud" Qty="5"/>
</Customer>
But for valid XML you can get the count:
"SET xyz = CARDINALITY(InputBody.Customer.ItemDetails[]);"
Regards,
aq |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 15, 2004 5:16 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
How do you know that CARDINALITY isn't working?
What value is it returning you for what input? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Fuzzy_mq |
Posted: Fri Oct 15, 2004 7:23 am Post subject: |
|
|
Apprentice
Joined: 27 May 2004 Posts: 31 Location: US
|
Guys hold on for some time, I am testing this and will let u know.. |
|
Back to top |
|
 |
Fuzzy_mq |
Posted: Fri Oct 15, 2004 9:43 am Post subject: |
|
|
Apprentice
Joined: 27 May 2004 Posts: 31 Location: US
|
Thanks Aq and jeff for the replies.
Aq your solution worked. Yes I am getting valid XML. For the post, I just typed in a sample XML.
Jeff I was goofing up with the syntax a bit. I was using
SET xyz = CARDINALITY(InputBody.Customer.ItemDetails.*[]);
and so I thought cardinality was not working but I was wrong.
Anyway all fine now...
Thanks a lot for your help.
Regards,
Suchit |
|
Back to top |
|
 |
|