ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » cardinality of an XML document

Post new topic  Reply to topic
 cardinality of an XML document « View previous topic :: View next topic » 
Author Message
KIARA
PostPosted: Fri May 14, 2004 7:08 am    Post subject: cardinality of an XML document Reply with quote

Newbie

Joined: 05 Mar 2004
Posts: 9

Hi ,
I am trying to loop in a msg flow using the cardinality of an XML message that has been exptracted from a SQL database and put to a queue using JDBC.

I AM REFERENCING THE CARDINALITY AS


declare i integer;
declare x integer;
set i = cardinality (InputRoot.XML.SQLMESSAGE.ROW[]);
set x=1;
while x <= i do

SET OutputRoot.XML.ACCOUNT_NO[x] = InputRoot.XML.SQLMESSAGE.ROW.account_no[x];

set x=x+1;

END WHILE;
set OutputRoot.XML.DATA = InputRoot.XML.SQLMESSAGE.DATA;

the code brings out only the first account code <ACCOUNT_NO>111111</ACCOUNT_NO>
, when I would expect it to bring out a list of the account codes
Has anyone any suggestions?
thanks
k.
Back to top
View user's profile Send private message
Missam
PostPosted: Fri May 14, 2004 7:13 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Code:
set i = cardinality (InputRoot.XML.SQLMESSAGE.ROW[]);

i think cardinality should be on account_no than on ROW
Code:
set i = cardinality (InputRoot.XML.SQLMESSAGE.ROW."acount_no"[]);
Back to top
View user's profile Send private message
KIARA
PostPosted: Fri May 14, 2004 7:21 am    Post subject: cardinality in XML Reply with quote

Newbie

Joined: 05 Mar 2004
Posts: 9

hi missam
thanks for the reply
yes , I tried that originally but still get the output as <ACCOUNT_NO>111111</ACCOUNT_NO>
there are definitely 2 line coming back from the database as I have fixed it for this, alos if I set the variable = 2 rather that the cardinality of the xml doc the massage fails.

Have you any more suggestions please?
Back to top
View user's profile Send private message
Missam
PostPosted: Fri May 14, 2004 7:28 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Quote:

alos if I set the variable = 2 rather that the cardinality of the xml doc the massage fails.


it fails because

Code:
SET OutputRoot.XML.ACCOUNT_NO[x] = InputRoot.XML.SQLMESSAGE.ROW.account_no[x];


for the above statement it creates two root elements and becomes an Invalid XML
Back to top
View user's profile Send private message
KIARA
PostPosted: Fri May 14, 2004 7:38 am    Post subject: Reply with quote

Newbie

Joined: 05 Mar 2004
Posts: 9

thanks for explaining that - have you any ideas why the code wont loop though using the cardinality function?
k.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri May 14, 2004 7:48 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

KIARA wrote:
thanks for explaining that - have you any ideas why the code wont loop though using the cardinality function?
k.


Use Environment.Variables.x and Environment.Variables.i instead of local integers, and see for yourself what is going on with tracing.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
JT
PostPosted: Fri May 14, 2004 8:02 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

KIARA,

I suggest you turn on a debug trace to see whether the ESQL code is invoking the while loop multiple times or the second occurrence of InputRoot.XML.SQLMESSAGE.ROW.account_no is actually NULL.

Based on your statement:
Quote:
alos if I set the variable = 2 rather that the cardinality of the xml doc the message fails.
my guess is the second occurrence of account_no is not there.
Quote:
there are definitely 2 line coming back from the database as I have fixed it for this
How do you know this is true? Did you display the cardinality value through a trace node or step through your program code with the debugger?
Back to top
View user's profile Send private message
KIARA
PostPosted: Mon May 17, 2004 1:16 am    Post subject: Reply with quote

Newbie

Joined: 05 Mar 2004
Posts: 9

hi
I know there are definitley 2 lines as when I bring the flow throught the debugger, I can see the 2 lines and all the values are correct for the 2 lines
Back to top
View user's profile Send private message
fschofer
PostPosted: Mon May 17, 2004 1:23 am    Post subject: Reply with quote

Knight

Joined: 02 Jul 2001
Posts: 524
Location: Mainz, Germany

Hi,

how many ROW element do you have ?

Maybe this works:

Code:
set i = cardinality (InputRoot.XML.SQLMESSAGE.ROW[]);
...
set OutputRoot.XML.ACCOUNT_NO[x] = InputRoot.XML.SQLMESSAGE.ROW[x].account_no;


Otherwise please post a trace of your incomming XML tree.

Greetings Frank
Back to top
View user's profile Send private message Send e-mail
KIARA
PostPosted: Mon May 17, 2004 3:13 am    Post subject: Reply with quote

Newbie

Joined: 05 Mar 2004
Posts: 9

hi again,
When I try the following as you suggested the messsage fails

declare i integer;
declare x integer;

set i = cardinality (InputRoot.XML.SQLMESSAGE.ROW[]);
set x = 1;
while x <= i do

set OutputRoot.XML.ACCOUNT_NO[x] = InputRoot.XML.SQLMESSAGE.ROW[x].account_no;
set x = x+ 1;
end while;

__________________________________________________________

but when I use ...
declare i integer;
declare x integer;
set i = cardinality (InputRoot.XML.SQLMESSAGE.ROW[]);
set x=1;
while x <= i do
SET OutputRoot.XML.ACCOUNT_NO[x] = InputRoot.XML.SQLMESSAGE.ROW.account_no[x];
set x=x+1;
END WHILE;

I get an output, but only one line!!
--------------------------------------------------------------------------------
below is an extract from the output trace - it says my output does not exist, thuis it deletes it - I didnt think I had to define an output for XML
fROM THE TRACE YOU CAN SEE THAT IT DOES PICK UP THE CARDINALITY FO THE INPUT AS 2 - IT GOES ON THEN TO Assigning NULL to 'OutputRoot.XML.ACCOUNT_NO', thus deleting it. -
Could you please tell me how to resolve this one
many thanks
kiara

Executing statement 'DECLARE i INTEGER;' at (16, 1).
Executing statement 'DECLARE x INTEGER;' at (17, 1).
Executing statement 'SET i = CARDINALITY(InputRoot.XML.SQLMESSAGE.ROW[ ]);' at (19, 1).
Evaluating expression 'CARDINALITY(InputRoot.XML.SQLMESSAGE.ROW[ ])' at (19, 9).
Finished evaluating expression 'CARDINALITY(InputRoot.XML.SQLMESSAGE.ROW[ ])' at (19, 9). The result was '2'.
Executing statement 'SET x = 1;' at (21, 1).
Executing statement 'WHILE x <= i DO ... END WHILE;' at (23, 1).
Evaluating expression 'x <= i' at (23, 7).
Evaluating expression 'x' at (23, 7).
Evaluating expression 'i' at (23, 12).
Node 'SOLAR_MSGFLOW.Compute2': Finished evaluating expression 'x <= i' at (23, 7). This resolved to '1 <= 2'. The result was 'TRUE'.
Executing statement 'SET OutputRoot.XML.ACCOUNT_NO[x] = InputRoot.XML.SQLMESSAGE.ROW.account_no[x];' at (25, 1).
Evaluating expression 'InputRoot.XML.SQLMESSAGE.ROW.account_no[x]' at (25, 36).
Evaluating expression 'x' at (25, 76).
Evaluating expression 'x' at (25, 31).
'SOLAR_MSGFLOW.Compute2': Performing tree copy of '' to 'OutputRoot.XML.ACCOUNT_NO'.
Executing statement 'SET x = x + 1;' at (29, 1).
Evaluating expression 'x + 1' at (29, .
Evaluating expression 'x' at (29, 7).
Node 'SOLAR_MSGFLOW.Compute2': Finished evaluating expression 'x + 1' at (29, . This resolved to '1 + 1'. The result was '2'.
Evaluating expression 'x <= i' at (23, 7).
Evaluating expression 'x' at (23, 7).
Evaluating expression 'i' at (23, 12).
Node 'SOLAR_MSGFLOW.Compute2': Finished evaluating expression 'x <= i' at (23, 7). This resolved to '2 <= 2'. The result was 'TRUE'.
Executing statement 'SET OutputRoot.XML.ACCOUNT_NO[x] = InputRoot.XML.SQLMESSAGE.ROW.account_no[x];' at (25, 1).
Evaluating expression 'InputRoot.XML.SQLMESSAGE.ROW.account_no[x]' at (25, 36).
Evaluating expression 'x' at (25, 76).
'SOLAR_MSGFLOW.Compute2': (25, 65) : Failed to navigate to path element because it does not exist.
Evaluating expression 'x' at (25, 31).
Evaluating expression 'x' at (25, 31).
'SOLAR_MSGFLOW.Compute2': Assigning NULL to 'OutputRoot.XML.ACCOUNT_NO', thus deleting it.
Executing statement 'SET x = x + 1;' at (29, 1).
Evaluating expression 'x + 1' at (29, .
Evaluating expression 'x' at (29, 7).
Node 'SOLAR_MSGFLOW.Compute2': Finished evaluating expression 'x + 1' at (29, . This resolved to '2 + 1'. The result was '3'.
Evaluating expression 'x <= i' at (23, 7).
evaluating expression 'x' at (23, 7).
Evaluating expression 'i' at (23, 12).
Node 'SOLAR_MSGFLOW.Compute2': Finished evaluating expression 'x <= i' at (23, 7). This resolved to '3 <= 2'. The result was 'FALSE'.
Message propagated to 'out' terminal of compute node 'SOLAR_MSGFLOW.Compute2'.
The MQ output node 'SOLAR_MSGFLOW.SOLAR_DATA_OUT' attempted to write a message to the specified queue 'SOLAR_DATA_OUT_OUT' connected to queue manager ''. The MQCC was 0 and the MQRC was 0.
Message successfully output by MQ output node 'SOLAR_MSGFLOW.SOLAR_DATA_OUT' to queue 'SOLAR_DATA_OUT_OUT' on queue manager ''.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » cardinality of an XML document
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.