Author |
Message
|
deepeshk79 |
Posted: Sun Dec 27, 2009 3:55 pm Post subject: Sequential processing of an XML |
|
|
Apprentice
Joined: 25 Mar 2007 Posts: 45 Location: Los Angeles
|
Hi,
I have the below simple code to navigate through an XML sequentially
Code: |
CREATE PROCEDURE navigate (IN root REFERENCE)
BEGIN
DECLARE cursor REFERENCE TO root;
DECLARE cursorname CHARACTER '';
SET cursorname = FIELDNAME(cursor);
MOVE cursor FIRSTCHILD;
WHILE LASTMOVE(cursor) DO
CALL navigate(cursor);
MOVE cursor NEXTSIBLING;
SET cursorname = FIELDNAME(cursor);
END WHILE;
END;
|
My input file looks like below
Code: |
<Task a='1' b='2'>
<print>test</print>
</Task>
|
My confusion here is that when my cursor is pointing at the attribute 'b' of Task tag, my NEXTSIBLING and FIRSTCHILD both should fail and the logic should throw me out of loop but it continues processing and gets me great results. Not sure how this works...
Any thoughts ?
Deepesh |
|
Back to top |
|
 |
Vitor |
Posted: Sun Dec 27, 2009 5:48 pm Post subject: Re: Sequential processing of an XML |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
deepeshk79 wrote: |
My confusion here is that when my cursor is pointing at the attribute 'b' of Task tag, my NEXTSIBLING and FIRSTCHILD both should fail and the logic should throw me out of loop but it continues processing and gets me great results. Not sure how this works... |
Why?
deepeshk79 wrote: |
Any thoughts ? |
Have another look at the structure of your XML. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Dec 27, 2009 10:43 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Working as designed. If you wanted to be thrown out of the loop you would need logic to check the fieldtype against the previous fieldtype...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
imakash |
Posted: Sun Dec 27, 2009 11:15 pm Post subject: |
|
|
Newbie
Joined: 22 Dec 2009 Posts: 7
|
<Print> is NEXT SIBLING of b |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Dec 28, 2009 7:26 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
Working as designed. If you wanted to be thrown out of the loop you would need logic to check the fieldtype against the previous fieldtype...  |
Or adjust the move statement  |
|
Back to top |
|
 |
deepeshk79 |
Posted: Mon Dec 28, 2009 3:24 pm Post subject: |
|
|
Apprentice
Joined: 25 Mar 2007 Posts: 45 Location: Los Angeles
|
I just wonder sometimes that how can <print> be next sibling to the attribute 'b'. Basically attribute 'b' is within element <Task> and its not having any siblings. <Print> is a child of <Task> of type element. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Dec 28, 2009 4:05 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Using a trace node would stop your wondering. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Dec 28, 2009 6:28 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
deepeshk79 wrote: |
I just wonder sometimes that how can <print> be next sibling to the attribute 'b'. |
I just wonder how you can ask such a thing. Assuming you've read anything on XML. Even if not, a brief examination of the parsed message tree will yield an explaination. Or the XML after it's been through any parser. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|