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 » extract the xml values in loop

Post new topic  Reply to topic
 extract the xml values in loop « View previous topic :: View next topic » 
Author Message
ydeonia
PostPosted: Wed May 08, 2013 11:06 pm    Post subject: extract the xml values in loop Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

Hi

I have an xml like

Code:
 <NS5:CAIAssembly>
          <NS5:CAIComponent >
            <NS5:CAICode>033144</NS5:CAICode>
            <NS5:Quantity>1</NS5:Quantity>
          </NS5:CAIComponent>
          <NS5:CAIComponent >
            <NS5:CAICode>048429</NS5:CAICode>
            <NS5:Quantity>1</NS5:Quantity>
          </NS5:CAIComponent>
          <NS5:CAIComponent >
            <NS5:CAICode>073528</NS5:CAICode>
            <NS5:Quantity>1</NS5:Quantity>
          </NS5:CAIComponent>
          <NS5:CAIComponent >
            <NS5:CAICode>563781</NS5:CAICode>
            <NS5:Quantity>1</NS5:Quantity>
          </NS5:CAIComponent>
        </NS5:CAIAssembly>


I have written like to get the values of

Code:

DECLARE LineCount INTEGER 1;
      DECLARE rResource REFERENCE TO orgObj.*:CAIAssembly.*:CAIComponent[1];
WHILE LASTMOVE(rResource) = TRUE DO   
      SET OutputRoot.XMLNSC.root.row[rowCnt].Kit_info.components[LineCount].productCd = COALESCE(FIELDVALUE(orgObj.*:ListOfCAD.*:CAD.*:CADAssembly.*:CADComponent.*:CAICode[1]),'0')||'_'||COALESCE(FIELDVALUE(orgObj.*:ListOfCAD.*:CAD.*:CADAssembly.*:CADComponent.*:CCIDCode[1]),'0');
      SET OutputRoot.XMLNSC.root.row[rowCnt].Kit_info.components[LineCount].quantity = FIELDVALUE(orgObj.*:CAIAssembly.*:CAIComponent.*:Quantity[1]);      
      SET LineCount = LineCount + 1;
MOVE rResource NEXTSIBLING REPEAT TYPE NAME;
      END WHILE;   


the above code give me result like only one

Code:
   <components>
    <productCd>033144_798</productCd>
    <quantity>1</quantity>
   </components>
   <components>
    <productCd>033144_798</productCd>
    <quantity>1</quantity>
   </components>
   <components>
    <productCd>033144_798</productCd>
    <quantity>1</quantity>
   </components>
   <components>
    <productCd>033144_798</productCd>
    <quantity>1</quantity>
   </components>


My ProductCd values are not iterating . Please help me to iterate the productCD values too. It should come like below pattern

Code:
<components>
<productCd >033144_5423</productCd >
<quantity>1</quantity>
</components>
<components>
<productCd >048429_5423</productCd >
<quantity>1</quantity>
</components>
<components>
<productCd >073528_5423</productCd >
<quantity>1</quantity>
</components>
<components>
<productCd >563781_5423</productCd >
<quantity>1</quantity>
</components>



Thanks all.


Last edited by ydeonia on Thu May 09, 2013 1:00 am; edited 2 times in total
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed May 08, 2013 11:16 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Look at using References and a WHILE LASTMOVE(...) type

something like this
Code:

   declare rResource REFERENCE to inRef.Resource;
   while lastmove(rResource) = true do
                -- do lots of good stuff here
      move rResource nextsibling repeat type name;
   end while;

_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
ydeonia
PostPosted: Wed May 08, 2013 11:27 pm    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

smdavies99 wrote:
Look at using References and a WHILE LASTMOVE(...) type

something like this
Code:

   declare rResource REFERENCE to inRef.Resource;
   while lastmove(rResource) = true do
                -- do lots of good stuff here
      move rResource nextsibling repeat type name;
   end while;


Thanks
You mean to say
Code:
DECLARE rResource REFERENCE TO orgObj.*:CAIAssembly.*:CAIComponent[1];

   WHILE LASTMOVE(rResource) = TRUE DO   
      SET OutputRoot.XMLNSC.root.row[rowCnt].Kit_info.components.productCd = COALESCE(FIELDVALUE(orgObj.*:ListOfCAD.*:CAD.*:CADAssembly.*:CADComponent.*:CAICode),'0')||'_'||COALESCE(FIELDVALUE(orgObj.*:ListOfCAD.*:CAD.*:CADAssembly.*:CADComponent.*:CCIDCode),'0');
      SET OutputRoot.XMLNSC.root.row[rowCnt].Kit_info.components.quantity = FIELDVALUE(orgObj.*:CAIAssembly.*:CAIComponent.*:Quantity);      
      MOVE rResource NEXTSIBLING REPEAT TYPE NAME;
      END WHILE;


Same output . Didnt worked
Back to top
View user's profile Send private message
kash3338
PostPosted: Thu May 09, 2013 1:13 am    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

ydeonia wrote:

Code:

OutputRoot.XMLNSC.root.row[rowCnt].Kit_info.components.productCd = COALESCE(FIELDVALUE(orgObj.*:ListOfCAD.*:CAD.*:CADAssembly.*:CADComponent.*:CAICode),'0')||'_'||COALESCE(FIELDVALUE(orgObj.*:ListOfCAD.*:CAD.*:CADAssembly.*:CADComponent.*:CCIDCode),'0');
      SET OutputRoot.XMLNSC.root.row[rowCnt].Kit_info.components.quantity = FIELDVALUE(orgObj.*:CAIAssembly.*:CAIComponent.*:Quantity);      
      MOVE rResource NEXTSIBLING REPEAT TYPE NAME;
      END WHILE;



Use rResource whiole doing the mapping. You are actually having a reference rResource and moving it to the next element, but while mapping you are always taking the first element from you input tree.

These two seem to be different,

Code:

orgObj.*:ListOfCAD.*:CAD.*:CADAssembly.*:CADComponent

and
Code:

DECLARE rResource REFERENCE TO orgObj.*:CAIAssembly.*:CAIComponent[1];
Back to top
View user's profile Send private message Send e-mail
ydeonia
PostPosted: Thu May 09, 2013 1:18 am    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

kash3338 wrote:

Use rResource whiole doing the mapping. You are actually having a reference rResource and moving it to the next element, but while mapping you are always taking the first element from you input tree.

These two seem to be different,

Code:

orgObj.*:ListOfCAD.*:CAD.*:CADAssembly.*:CADComponent

and
Code:

DECLARE rResource REFERENCE TO orgObj.*:CAIAssembly.*:CAIComponent[1];


Bu when i take

Code:
DECLARE rResource REFERENCE TO orgObj.*:CAIAssembly.*:CAIComponent[];

its gives error.

what should I change here to get values as now I am getting same.
Back to top
View user's profile Send private message
ydeonia
PostPosted: Thu May 09, 2013 2:00 am    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

Thanks issue is solved. I need to iterate the tree not the value. Thanks all
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 » extract the xml values in loop
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.