Author |
Message
|
adoyle65 |
Posted: Wed Feb 18, 2004 1:26 pm Post subject: NextSibling Why does this not work |
|
|
Apprentice
Joined: 18 Feb 2004 Posts: 37 Location: Canada
|
I have read the section in the ESQL book on anonymous references and I have followed it here, but this does not work. Anyone know why?
here is the XML message
<GenericForm>
<FormID>
GenericForm4.jsp
</FormID>
<MailTO>jjohnston@notesmail.olc</MailTO>
<MailCC>adoyle@notesmail.olc</MailCC>
<MailBCC>EmailBCCaddress@olgc.ca</MailBCC>
<MailFrom>EmailFromaddress@olgc.ca</MailFrom>
<MailSubject>OLGC Feedback Form Sample Form Message</MailSubject>
<FormElement>
<Description>First Name</Description>
<Value>Jeffrey</Value>
</FormElement>
<FormElement>
<Description>Last Name</Description>
<Value>Johnston</Value>
</FormElement>
<FormElement>
<Description>Street Address</Description>
<Value>Hwy 552 West</Value>
</FormElement>
<FormElement>
<Description>City</Description>
<Value>Goulais River</Value>
</FormElement>
<FormElement>
<Description>Province</Description>
<Value>Ontario</Value>
</FormElement>
<FormElement>
<Description>Postal Code</Description>
<Value>P0S1E0</Value>
</FormElement>
<FormElement>
<Description>Department</Description>
<Value>IT</Value>
</FormElement>
<FormElement>
<Description>Position</Description>
<Value>SDA</Value>
</FormElement>
</GenericForm>
MOVE myref TO InputRoot.XML.GenericForm.FormElement;
WHILE (LASTMOVE(myref)=TRUE) DO
SET OutputRoot.XML.Message.Body.Line[LineCount] = myref.Description || ':';
SET LineCount = LineCount + 1;
SET OutputRoot.XML.Message.Body.Line[LineCount] = myref.Value || NewLine;
SET LineCount = LineCount + 1;
MOVE myref NEXTSIBLING;
END WHILE; |
|
Back to top |
|
 |
Missam |
Posted: Wed Feb 18, 2004 1:34 pm Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
Are you getting any errors ...? |
|
Back to top |
|
 |
adoyle65 |
Posted: Wed Feb 18, 2004 1:50 pm Post subject: Here is the event viewer message. |
|
|
Apprentice
Joined: 18 Feb 2004 Posts: 37 Location: Canada
|
I understand that it is saying that I am trying to assign to OutputRoot.XML.Body.Line[2] and that Line[1] does not exist but this is not the case as far as I can see.
Invalid indexed assignment to Line[2].
No indexed elements from the named array exist. In order to assign a value to an element with index n, where 'n' is a positive integer, n-1 elements with the same name must already exist.
Ensure that element n-1 is created before an attempt is made to create element n.
Thanks
Aidan |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Feb 18, 2004 1:59 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Please show us the complete ESQL in the node that is failing.
Or at least, show us all of the ESQL that is associated with this particular task, including where you inititiallize all the variables that you use - like where you initialize LineCount. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Missam |
Posted: Wed Feb 18, 2004 3:36 pm Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
The Possibilty is in your code
Code: |
SET OutputRoot.XML.Message.Body.Line[1] = myref.Description ||
':';
|
myref.Description may be Derived to NULL and the SubTree
SET OutputRoot.XML.Message.Body.Line became NULL
And it can't create the element
SET OutputRoot.XML.Message.Body.Line[2]
This is what the Index Problem. |
|
Back to top |
|
 |
adoyle65 |
Posted: Wed Feb 18, 2004 4:18 pm Post subject: |
|
|
Apprentice
Joined: 18 Feb 2004 Posts: 37 Location: Canada
|
The only code other than what I have already included are the following statements
DECLARE LineCount INT;
DECLARE myref REFERENCE TO InputRoot.XML.GenericForm.FormElement[1];
SET LineCount = 1;
Thanks |
|
Back to top |
|
 |
mgk |
Posted: Thu Feb 19, 2004 7:09 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hi,
The following ESQL works for me, but as I am not exactly sure what you were trying to achieve I had to guess in places. Essentially, NewLine was undefined (I assumed you defined it in your ESQL as a CRLF) and I removed a redundent MOVE and redundent comparison on the WHILE.
The main problem however was the missing REPEAT clauses on the MOVE statement. These allow you to skip extra whitespace elements in the incoming XML message (elements such as CRLF, SP. TAB etc) which are encoded as elements in the tree. When you tried to use the MOVE without repeat, your next sibbling was a "whitepsace" element which did not have a "description" child, and so the first "Line" was not created, and so the ESQL failed when you tried to access Line[2] when Line[1] did not exist. This is essentially what IamSam said.
Code: |
SET OutputRoot.MQMD = InputRoot.MQMD;
DECLARE LineCount INTEGER 1;
DECLARE NewLine CHAR CAST(X'0D0A' AS CHARACTER CCSID 1208);
DECLARE myref REFERENCE TO InputRoot.XML.GenericForm.FormElement[1];
WHILE LASTMOVE(myref) DO
SET OutputRoot.XML.Message.Body.Line[LineCount] = myref.Description || ':' ;
SET LineCount = LineCount + 1;
SET OutputRoot.XML.Message.Body.Line[LineCount] = myref.Value || NewLine;
SET LineCount = LineCount + 1;
MOVE myref NEXTSIBLING REPEAT TYPE NAME;
END WHILE; |
The following is my output message:
Code: |
<Message><Body><Line>First Name:</Line><Line>Jeffrey
</Line><Line>Last Name:</Line><Line>Johnston
</Line><Line>Street Address:</Line><Line>Hwy 552 West
</Line><Line>City:</Line><Line>Goulais River
</Line><Line>Province:</Line><Line>Ontario
</Line><Line>Postal Code:</Line><Line>P0S1E0
</Line><Line>Department:</Line><Line>IT
</Line><Line>Position:</Line><Line>SDA
</Line></Body></Message> |
Cheers, _________________ 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 |
|
 |
adoyle65 |
Posted: Thu Feb 19, 2004 7:25 am Post subject: REPEAT TYPE NAME problem |
|
|
Apprentice
Joined: 18 Feb 2004 Posts: 37 Location: Canada
|
Thanks mgk and all you guys.
Agree completely with what you and IamSam stated. I kinda figured that was the problem I was not sure what was causing it though. You were correct that NewLine is defined as a CRLF. I have to follow your example but I get a syntax error when I use the REPEAT TYPE NAME in my move statement.
Any clues???
Thanks in advance |
|
Back to top |
|
 |
Missam |
Posted: Thu Feb 19, 2004 7:32 am Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
What is the Error Description
Code: |
MOVE myref NEXTSIBLING REPEAT TYPE NAME;
|
should work fine.
What Level of CSD's are you working on.[/code] |
|
Back to top |
|
 |
mgk |
Posted: Thu Feb 19, 2004 7:36 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
What Version and CSD of broker are you running? I assume that the error is because you are on a CSD before it was introduced and I forget which CSD that what, but I think it was 2.1 CSD3 (ish). However, if you remove all the CRLF / whitespace formatting from your input message as a test, you should find it work without the REPEAT ... clause, as there will be no whitespace elements created....
Cheers, _________________ 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 |
|
 |
Missam |
Posted: Thu Feb 19, 2004 7:49 am Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
Its working fine for me on CSD2 |
|
Back to top |
|
 |
adoyle65 |
Posted: Thu Feb 19, 2004 8:49 am Post subject: Level |
|
|
Apprentice
Joined: 18 Feb 2004 Posts: 37 Location: Canada
|
Hi guys,
Version 2.1 CSD02
I do not get a runtime error I get a syntax error in the ESQL pane.
Thanks |
|
Back to top |
|
 |
Missam |
Posted: Thu Feb 19, 2004 10:16 am Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
Can u post the error here. |
|
Back to top |
|
 |
adoyle65 |
Posted: Thu Feb 19, 2004 11:07 am Post subject: OK Seems to be working. |
|
|
Apprentice
Joined: 18 Feb 2004 Posts: 37 Location: Canada
|
Hi Guys,
As I said earlier my ESQL pane continually complained about a syntax error and the cursor would blink red at the REPEAT TYPE NAME code. I decided to try and check in the flow and deploy it to see if I could provide you with any errors from the log pane. It deployed fine to my surprise and seems to work OK also.
I appreciate all of your help and patience.
Thanks Again
Aidan[/img] |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 19, 2004 12:12 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Sounds like you did not apply CSD02 to your Control Center machine. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|