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 » CREATE NEXTSIBLING

Post new topic  Reply to topic
 CREATE NEXTSIBLING « View previous topic :: View next topic » 
Author Message
Chuck831
PostPosted: Sun Oct 09, 2005 10:46 am    Post subject: CREATE NEXTSIBLING Reply with quote

Apprentice

Joined: 23 Dec 2002
Posts: 28

Hello,

I'm trying to create the following XML:
Code:

<NS1:Data>
  <NS1:AcctNo>123</NS1:AcctNo>
  <NS1:Addresses>
    <Ns2:Addr>
       <NS2:Street>123 Main Street</NS2:Street>
       <NS2:City>Orlando</NS2:City>
    </NS2:Addr>
    <Ns2:Addr>
       <NS2:Street>3 Union St</NS2:Street>
       <NS2:City>Chicago</NS2:City>
    </NS2:Addr>
  </NS1:Addresses>
<NS1:Data>
   


I have tried using an array subscript and can create the first occurance fine. But when I attempt to create the second occurance I get a subscript out of range exception.

Code:

Set I = I + 1;
Set OutputRoot.XMLNS.NS1:Data.NS1:Addresses.NS2:Addr[I].NS2:Street = ......
Set OutputRoot.XMLNS.NS1:Data.NS1:Addresses.NS2:Addr[I].NS2:City = ......

 


I have also tried using the CREATE NEXTSIBLING statement:

Code:


CREATE NEXTSIBLING OF OutputRoot.XMLNS.NS1:Data.NS1:Addresses.NS2:Addr  DOMAIN 'XMLNS' NAME 'Addr';



There could be 1, 2 or more occurances of the Addr tag. Could someone point me in the right direction.

Thanks.
Chuck
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sun Oct 09, 2005 3:55 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Both constructs should work just fine.

We can't tell what's wrong without more context.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
javaforvivek
PostPosted: Sun Oct 09, 2005 10:01 pm    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

ANy be you can try with LASTCHILD as well... so many posts on this topic.. the most recent one is by Lilian:
http://www.mqseries.net/phpBB2/viewtopic.php?t=24723
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Chuck831
PostPosted: Mon Oct 10, 2005 7:33 am    Post subject: Reply with quote

Apprentice

Joined: 23 Dec 2002
Posts: 28

Let me try to shed more light. After I create the first occurance of <NS2:Addr> I created a procedure to create additional occcurances.

When the I attempt to create the second occurance of <NS2.Addr[2]><NS2:Street> I get an array subscript error. However, if I don't use the procedure it works fine. But I have to create possibly 10 of the same structure and the procedure cuts down on the amount of code.

Any thoughts would be greatly appreciated.

Thanks.

Code:

Set I = 1;
Set OutputRoot.XMLNS.NS1:Data.NS1.Addresses.NS2.Addr[I].NS2:Street =....
Set OutputRoot.XMLNS.NS1:Data.NS1.Addresses.NS2.Addr[I].NS2:City =....

If InputBody.CustomerData.BillingAddr = 'Y' Then
   CREATE NEXTSIBLING OF OutputRoot.XMLNS.NS1:Data.NS1:Addresses.NS2:Addr  DOMAIN 'XMLNS' NAME 'Addr';
    Set TmpField       = ......
    Set TmpAttribValue = ......
    CALL CreateCustomAttribute(TmpField, TmpAttribValue, I);
    End If;

If InputBody.CustomerData.Office = 'Y' Then
   CREATE NEXTSIBLING OF OutputRoot.XMLNS.NS1:Data.NS1:Addresses.NS2:Addr  DOMAIN 'XMLNS' NAME 'Addr';
    Set TmpField       = ......
    Set TmpAttribValue = ......
    CALL CreateCustomAttribute(TmpField, TmpAttribValue, I);
    End If;

END;

CREATE PROCEDURE CreateCustomAttribute(IN TmpField Char, IN TmpAttribValue Char, INOUT I INTEGER)
   
BEGIN
Set I = I + 1;
Set OutputRoot.XMLNS.NS1:Data.NS1.Addresses.NS2.Addr[I].NS2:Street =....
Set OutputRoot.XMLNS.NS1:Data.NS1.Addresses.NS2.Addr[I].NS2:City =....

END;

END MODULE;

Back to top
View user's profile Send private message
JT
PostPosted: Mon Oct 10, 2005 8:49 am    Post subject: Reply with quote

Padawan

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

In the called procedure you're establishing the repeating occurrences through the SET command, so element the CREATE NEXTSIBLING statements and see if you get the results you expect.
Back to top
View user's profile Send private message
Chuck831
PostPosted: Mon Oct 10, 2005 10:02 am    Post subject: Reply with quote

Apprentice

Joined: 23 Dec 2002
Posts: 28

JT

I don't understand what you mean by "ELEMENT" the CREATE NEXTSIBLING statement.
Back to top
View user's profile Send private message
JT
PostPosted: Mon Oct 10, 2005 10:28 am    Post subject: Reply with quote

Padawan

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

Sorry, a typo. I had 'XML element' on my mind.

It should read:

Quote:
so eliminate the CREATE NEXTSIBLING statements and see if you get the results you expect.
Back to top
View user's profile Send private message
mgk
PostPosted: Mon Oct 10, 2005 1:59 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

You may have a typo in your posting, but your code was so heavily cropped I cannot be sure. However, you start by coding:

CREATE NEXTSIBLING OF OutputRoot.XMLNS.NS1:Data.NS1:Addresses.NS2:Addr DOMAIN 'XMLNS' NAME 'Addr';


Note NS2:Addr which is an element called Addr in the namepace NS2. Also note that the DOMAIN clause here is definately NOT needed and could be harmful used in this context.

That aside, inside your procedure, you reference:

Set OutputRoot.XMLNS.NS1:Data.NS1.Addresses.NS2.Addr[I].NS2:Street

Note the period (.) between NS2 and Addr. This will create an element called NS2 and then create an element Addr inside it then index the i'th occurence which will not exist, so hence the exception. The period should be a colon (

If this is simply a typo when you posted the message then make sure you are not incrementing I once before your procedure call and again inside it (and missing an element in the process) as this could also give you this problem as you increment I at the top of the procedure, and you may actually only want to increment it at the end.

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
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 » CREATE NEXTSIBLING
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.