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 » XMLNS parsing

Post new topic  Reply to topic
 XMLNS parsing « View previous topic :: View next topic » 
Author Message
swaugh
PostPosted: Mon Feb 25, 2008 5:49 pm    Post subject: XMLNS parsing Reply with quote

Apprentice

Joined: 15 Jun 2006
Posts: 37

Hi ,
I am having an issue parsing XML attributes using XMLNS domain.
The Input message looks like this

<eims2:Role type="Sales">
<oa9:Code>SalesResource</oa9:Code>
</eims2:Role>
<eims2:Role type="FMSRole">
<oa9:Code>RGSHH</oa9:Code>
</eims2:Role>

I am trying to parse the element value of oa9:code for an attribute value of Role type ="FMSRole". I need to access the value "RGSHH" from the above tree.

I have the following esql

SET VFMSJOBROLECODE = THE(Select Item I from InputRoot.eims2:Role.oa9:Code AS I where I.(XML.Attribute)type='FMSRole');

but the above esql statement doesnt work.

Any help in this regard is appreciated
Thanks,
Swaugh
Back to top
View user's profile Send private message
gregop
PostPosted: Tue Feb 26, 2008 12:11 am    Post subject: Reply with quote

Voyager

Joined: 24 Nov 2006
Posts: 81

Quote:
SET VFMSJOBROLECODE = THE(Select Item I from InputRoot.eims2:Role.oa9:Code AS I where I.(XML.Attribute)type='FMSRole');


Firstly (possibly a typo in your post) you're using XMLNS parser so you want InputRoot.XMLNS

Secondly you want to look over each instance of eims2:role not just the first instance of eims2:role.oa9:Code you'll need to do something like:

SET VFMSJOBROLECODE = THE(Select Item I.oa9:Code from InputRoot.XMLNS.eims2:Role[] AS I where I.(XML.Attribute)type='FMSRole');
Back to top
View user's profile Send private message
swaugh
PostPosted: Tue Feb 26, 2008 2:02 pm    Post subject: Reply with quote

Apprentice

Joined: 15 Jun 2006
Posts: 37

Thanks for the reply. when i use the suggested esql

SET VFMSJOBROLECODE = THE(Select Item I.oa9:Code from InputRoot.XMLNS.eims2:Role[] AS I where I.(XML.Attribute)type='FMSRole');

i get the first value correctly, that is the oa9:Code= 'SalesResource when type is 'Sales', if i change the value to 'FMSRole' then i get null assignment. Looks like the syntax

THE(Select Item I from InputRoot.eims2:Role.oa9:Code AS I where I.(XML.Attribute)type='FMSRole');

returns the first occurence. Am i missing anything.
Back to top
View user's profile Send private message
mgk
PostPosted: Tue Feb 26, 2008 3:45 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

The attribute type does not exist on the oa9:Code element, it exists on the eims2:Role element. And when you say "AS I" I becomes the element at the end of the path, in this case oa9:Code. Therefore, you are going too "deep" in the message, you need to stop at eims2:Role.
_________________
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
swaugh
PostPosted: Tue Feb 26, 2008 4:04 pm    Post subject: Reply with quote

Apprentice

Joined: 15 Jun 2006
Posts: 37

Tis is the syntax I have

SET VFMSJOBROLECODE = The(Select Item I.oa9:Code from VTERRITORYHEADER.eims2:Role[] AS I where VTERRITORYHEADER.eims2:Role.(XML.Attribute)type='FMSRole');

It yields null.
Back to top
View user's profile Send private message
swaugh
PostPosted: Tue Feb 26, 2008 4:25 pm    Post subject: Reply with quote

Apprentice

Joined: 15 Jun 2006
Posts: 37

It looks like assignment issue. I have declared VFMSJOBROLECODE as character and its not able to hold the result arising from

SET VFMSJOBROLECODE = THE(Select Item I from InputRoot.eims2:Role.oa9:Code AS I where I.(XML.Attribute)type='FMSRole');

If i change the assignment variable from SET VFMSJOBROLECODE TO
SET OUTPUTROOT.XML.FMSJOBROLECODE, i am able to see the value in the output root tree.

I guess the assignment type is the issue.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Feb 27, 2008 1:37 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Code:
SET OUTPUTROOT.XML.FMSJOBROLECODE

There is no good reason to write new code which uses the XML domain. Please switch to XMLNS.
Back to top
View user's profile Send private message
swaugh
PostPosted: Tue Mar 04, 2008 5:49 pm    Post subject: Reply with quote

Apprentice

Joined: 15 Jun 2006
Posts: 37

Adding to the same XML complex structure, i have an XML tree something like this
<Territory>
<eims2:Role type="Sales">
<oa9:Code>SalesResource</oa9:Code>
</eims2:Role>
<eims2:Role type="FMSRole">
<oa9:Code>RGSHH</oa9:Code>
</eims2:Role>
<eims2:Role type= "FRSRole">
<oa9:Code>GTS000000001</oa9:Code>
<oa9:Description>TEST FRS GTS ROLE</oa9:Description>
<eims2:SubRole type="BrandGroup">
<oa9:Description>GTS</oa9:Description>
</eims2:SubRole>
<eims2:SubRole type="ResourceCategory">
<oa9:Description>TESTGTS</oa9:Description>
</eims2:SubRole>
<eims2:SubRole type="ProductLevel1">
<oa9:Description>ABC</oa9:Description>
</eims2:SubRole>
<eims2:SubRole type="ProductLevel2">
<oa9:Description>123</oa9:Description>
</eims2:SubRole>
<eims2:SubRole type="ProductLevel3">
<oa9:Description>DEF</oa9:Description>
</eims2:SubRole>
</eims2:Role>
</Territory>

I am trying to parse the value of sub role type = Resource Category (value is TESTGTS)
<eims2:SubRole type="ResourceCategory">
<oa9:Description>TESTGTS</oa9:Description>
</eims2:SubRole>[/color]

and I have the following ESQL code

SET VBRANDGROUP = The(Select Item I.eims2:SubRole.oa9:Description from InputRoot.XMLNS.Territory.eims2:Role[] AS I where I.(XML.Attribute)type='FRSRole' and I.(XML.Attribute)type='ResourceCategory');

I am getting VBRANDGROUP as Null.

If i modify the above ESQL where condition to

SET VBRANDGROUP = The(Select Item I.eims2:SubRole.oa9:Description from InputRoot.XMLNS.Territory.eims2:Role[] AS I where I.(XML.Attribute)type='FRSRole');

i get the first occurence oa9:Description value = GTS.

How do i get the oa9:Description value for eims2:SubRole type="ResourceCategory">
<oa9:Description>TESTGTS</oa9:Description>
</eims2:SubRole>[/color]

thanks,
Swaugh
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Mar 05, 2008 2:23 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

I may be misunderstanding what you are trying to do, but this code:

Code:
... AS I.(XML.Attribute)type='FRSRole' and I.(XML.Attribute)type='ResourceCategory')


Will only match elements that have two type attributes, one with a value of 'FRSRole' and one with a value of 'ResourceCategory'. And as I believe that you cannot have two attributes of the same name on an element in XML then this will never match anything, so you will always get NULL back.

If you want to find element with the type of 'ResourceCategory' what is wrong with using;

Code:
... AS I where I.(XML.Attribute)type='ResourceCategory'?



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
swaugh
PostPosted: Wed Mar 05, 2008 5:32 pm    Post subject: Reply with quote

Apprentice

Joined: 15 Jun 2006
Posts: 37

If u see Sub Role Xml tag is under the Role tag of type ='FRSRole'

I tried the esql like

SET VBRANDGROUP = The(Select Item I.eims2:SubRole.oa9:Description from InputRoot.XMLNS.Territory.eims2:Role[] AS I where I.eims2:SubRole.(XML.Attribute)type='ResourceCategory');

still it yields null. Looks like its not nvaigating to the SubRole element under Role type="FRSRole"

Only code thats navigating to SubRole Tree is
Code:
SET VBRANDGROUP = The(Select Item I.eims2:SubRole.oa9:Description from InputRoot.XMLNS.Territory.eims2:Role[] AS I where I.(XML.Attribute)type='FRSRole');
where we get the first occurence of description value under sub role type = BrandGroup

any ideas, where i am committing the mistake?
Back to top
View user's profile Send private message
gregop
PostPosted: Thu Mar 06, 2008 12:09 am    Post subject: Reply with quote

Voyager

Joined: 24 Nov 2006
Posts: 81

You'll be needing a select within a select.

This snippet will return the Roles that you are interested in:

Select I from InputRoot.eims2:Role[] AS I where I.(XML.Attribute)type='FMSRole');

Then select from that list to return the SubRole required so something like this:

SET VBRANDGROUP = The(Select Item J.eims2:SubRole.oa9:Description from (Select I from InputRoot.eims2:Role[] AS I where I.(XML.Attribute)type='FMSRole') AS J WHERE J.eims2:SubRole.(XML.Attribute)type='ResourceCategory');
Back to top
View user's profile Send private message
swaugh
PostPosted: Thu Mar 06, 2008 5:34 pm    Post subject: Reply with quote

Apprentice

Joined: 15 Jun 2006
Posts: 37

Thanks for the tip on nested select.
Code:

SET VBRANDGROUP = The(Select Item J.eims2:SubRole.oa9:Description from (Select I from InputRoot.eims2:Role[] AS I where I.(XML.Attribute)type='FMSRole') AS J WHERE J.eims2:SubRole.(XML.Attribute)type='ResourceCategory');



but the above mentioned code is returning ESQL error, the esql compiler is not liking the nested select in the from clause. any ideas?

thanks,
Swaugh
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 » XMLNS parsing
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.