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 » Is there a way to find XML tag using wildcard ?

Post new topic  Reply to topic Goto page Previous  1, 2
 Is there a way to find XML tag using wildcard ? « View previous topic :: View next topic » 
Author Message
Vitor
PostPosted: Thu Dec 08, 2011 8:11 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

KIT_INC wrote:
Iterating FROM clause.


So what are the next few lines of the trace? It seems to be trying to iterate.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
KIT_INC
PostPosted: Thu Dec 08, 2011 8:44 am    Post subject: Reply with quote

Knight

Joined: 25 Aug 2006
Posts: 589

Here is something interesting
If there is no match on the first TAG, the broker will stop looking, as seen in the trace. I think this is what " Iterating FROM clause " means

2011-12-08 11:20:44.707996 3856 UserTrace BIP2539I: Node 'TEST_WILDCARD_FIELDNAME.Compute': Evaluating expression

''FIELDNAME(T.*:*) LIKE 'BO%''' at ('.TEST_WILDCARD_FIELDNAME_Compute.CopyEntireMessage', '34.92'). This resolved to '''AA'

LIKE 'BO%' ESCAPE '\'''. The result was ''FALSE''.
2011-12-08 11:20:44.708023 3856 UserTrace BIP2569W: Node 'TEST_WILDCARD_FIELDNAME.Compute':

('.TEST_WILDCARD_FIELDNAME_Compute.CopyEntireMessage', '34.34') : WHERE clause evaluated to false or unknown. Iterating FROM clause.

2011-12-08 11:20:44.708339 3856 UserTrace BIP2570W: Node 'TEST_WILDCARD_FIELDNAME.Compute': '.TEST_WILDCARD_FIELDNAME_Compute.CopyEntireMessage', '34.34') : There were no items in the FROM clause satisfying the WHERE clause.

I ran the test again by moving the BO123 tag to the first and add a BO124 tag in the middle.
<MSG>
<BO123>1234567</BO123>
<AA>11</AA>
<BB>22</BB>
<CC>33</CC>
<DD>44</DD>
<EE>55</EE>
<FF>66</FF>
<BO124>ABCD</BO124>
<GG>77</GG>
</MSG>


It will get a match with the BO123 and try to continue to look. As indicated in the trace "Finding next SELECT result. " However it can not find the next BO124 tag.

2011-12-08 11:16:42.734634 3856 UserTrace BIP2540I: Node 'TEST_WILDCARD_FIELDNAME.Compute': Finished evaluating expression ''FIELDNAME(T.*:*)'' at ('.TEST_WILDCARD_FIELDNAME_Compute.CopyEntireMessage', '34.77'). The result was '''BO123'''.
2011-12-08 11:16:42.734783 3856 UserTrace BIP2539I: Node 'TEST_WILDCARD_FIELDNAME.Compute': Evaluating expression ''FIELDNAME(T.*:*) LIKE 'BO%''' at ('.TEST_WILDCARD_FIELDNAME_Compute.CopyEntireMessage', '34.92'). This resolved to '''BO123' LIKE 'BO%' ESCAPE '\'''. The result was ''TRUE''.
2011-12-08 11:16:42.734840 3856 UserTrace BIP2562I: Node 'TEST_WILDCARD_FIELDNAME.Compute': Assigning a list to ''Environment.DATA[]''.
2011-12-08 11:16:42.735717 3856 UserTrace BIP2539I: Node 'TEST_WILDCARD_FIELDNAME.Compute': Evaluating expression ''T.*:*'' at ('.TEST_WILDCARD_FIELDNAME_Compute.CopyEntireMessage', '34.34'). This resolved to ''T.*:*''. The result was ''ROW... Root Element Type=50331648 NameSpace='' Name='BO123' Value='1234567'''.
2011-12-08 11:16:42.735923 3856 UserTrace BIP2568I: Node 'TEST_WILDCARD_FIELDNAME.Compute': Copying sub-tree from ''T.*:*'' to ''Environment.DATA[1]''.
2011-12-08 11:16:42.736175 3856 UserTrace BIP2574W: Node 'TEST_WILDCARD_FIELDNAME.Compute': ('.TEST_WILDCARD_FIELDNAME_Compute.CopyEntireMessage', '34.34') : Finding next SELECT result.
2011-12-08 11:16:42.736518 3856 UserTrace BIP2571W: Node 'TEST_WILDCARD_FIELDNAME.Compute': ('.TEST_WILDCARD_FIELDNAME_Compute.CopyEntireMessage', '34.34') : Failed to find any more items in the FROM clause satisfying the WHERE clause.
Back to top
View user's profile Send private message
inMo
PostPosted: Thu Dec 08, 2011 10:38 am    Post subject: Reply with quote

Master

Joined: 27 Jun 2009
Posts: 216
Location: NY

Does the XML have a defined schema? Or in even simpler terms (for me, not you) does it have a reliable structure? Is it true that you have to process 1 to n branches depending on the presence of 1 to n <BO###> tags, or is this lways a single <BO###> tag?
Back to top
View user's profile Send private message
KIT_INC
PostPosted: Thu Dec 08, 2011 11:07 am    Post subject: Reply with quote

Knight

Joined: 25 Aug 2006
Posts: 589

There is no schema. In my case there is one BOxxx tag. The reason I add the 2nd one in my test is to see if it will continue to look after the first match. I think that the select statement that I use will provide an array containing value of tags that match the pattern. I ssems that it will stop looking after the first unmatch.

For my need, as long as it can find the first BOxxx , I am happy.
Back to top
View user's profile Send private message
inMo
PostPosted: Thu Dec 08, 2011 11:30 am    Post subject: Reply with quote

Master

Joined: 27 Jun 2009
Posts: 216
Location: NY

Ok - Looking for a single <BOxxx> tag. Some narrowing of focus questions:

Is the <BOxxx> tag always in the same location? (ie. the fifth element under the root tag?) If not, Is the <BOxxx> tag always in the same grouping of elements? (ie. always 1 level under the root tag, but never under a child element of root (Root.Child1.BOxxx))
Back to top
View user's profile Send private message
KIT_INC
PostPosted: Thu Dec 08, 2011 12:08 pm    Post subject: Reply with quote

Knight

Joined: 25 Aug 2006
Posts: 589

I was not able to get confirmation. Since there is no schema, I can not rely on which tag is alway above or below the BOxxx tag. I can only confirm that it is alway at the same level. I have written code that position myself at the first TAG of the level and walk by nextsibling until I find BOxxx. But that seems to be not very efficient because it can be the 500th TAG at that level. That's why I ask about select with pattern match.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Dec 09, 2011 1:48 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
there is no schema
Quote:
it can be the 500th TAG at that level
So you're dealing with a large data structure, and you don't know what the rules for the structure are. Nevertheless, you need to efficiently extract a field from an unknown position in that structure.

Seems to me that inMo is on the right lines here. Instead of trying to make a brute-force search ( a little bit ) more efficient, why not try to get some more information about the structure of this thing. You might find that everything suddenly becomes a *lot* easier.
Back to top
View user's profile Send private message
HOMETOWN47
PostPosted: Fri Dec 09, 2011 3:56 am    Post subject: Reply with quote

Apprentice

Joined: 25 Mar 2003
Posts: 34

Try:-

Code:
SET Environment.Data[] = (SELECT *  FROM InputRoot.XMLNSC.Msg.*[] AS T WHERE FIELDNAME(T) LIKE 'BO%');


From help:-
Quote:

Using anonymous field references
You can refer to the array of all children of a particular element by using a path element of *.

For example:

InputRoot.*[]is a path that identifies the array of all children of InputRoot. This is often used in conjunction with an array subscript to refer to a particular child of an entity by position, rather than by name.



My test mesage:-

Code:
<Msg>
<BO124>1237</BO124>
<AA>11</AA>
<BB>22</BB>
<CC>33</CC>
<DD>44</DD>
<BO123>1234567</BO123>
<EE>55</EE>
<FF>66</FF>
<BO13>1232</BO13>
<GG>77</GG>
</Msg>


returned:-

Code:
WMQI_Environment
   Data:CHARACTER:1237
   Data:CHARACTER:1234567
   Data:CHARACTER:1232
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Dec 09, 2011 5:05 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

I don't think that the '*' is specifically needed, although that could just be bad habits from old days getting in the way of correctly cited documentation.

Either way,
Back to top
View user's profile Send private message
mgk
PostPosted: Fri Dec 09, 2011 6:26 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Quote:
I don't think that the '*' is specifically needed


The '*' should always be used to mean "name is absent" or "any name"


Kind 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
KIT_INC
PostPosted: Fri Dec 09, 2011 9:22 am    Post subject: Reply with quote

Knight

Joined: 25 Aug 2006
Posts: 589

Thanks HOMETOWN47,
Your statement works
SET Environment.Data[] = (SELECT * FROM InputRoot.XMLNSC.Msg.*[] AS T WHERE FIELDNAME(T) LIKE 'BO%') ;

I now have the contebt of the BOxxx TAG in Environment.Data.

Is there a way to get the name of the TAG because I need to pickup the branch office number xxx which unfortunately is only in the TAG and not the content. I have read the Selectclause of the info center many times and cannot figure out how to do it.
Sorry about asking for hand holding.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Dec 09, 2011 9:39 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

KIT_INC wrote:
I have read the Selectclause of the info center many times and cannot figure out how to do it.
Sorry about asking for hand holding.


Code:
SELECT FIELDNAME(*) FROM InputRoot.XMLNSC.Msg.*[] AS T WHERE FIELDNAME(T) LIKE 'BO%') ;


is my untested suggestion
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mgk
PostPosted: Fri Dec 09, 2011 10:01 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Almost, use this:

Code:
SET OutputRoot.XMLNSC.Top.Data2[] = (SELECT T As TagValue, FIELDNAME(T) AS TagName FROM InputRoot.XMLNSC.Msg.*[] AS T WHERE FIELDNAME(T) LIKE 'BO%');


Kind 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
KIT_INC
PostPosted: Fri Dec 09, 2011 12:08 pm    Post subject: Reply with quote

Knight

Joined: 25 Aug 2006
Posts: 589

Hi mgk,
SELECT T As TagValue, FIELDNAME(T) AS TagName FROM InputRoot.XMLNSC.Msg.*[] AS T WHERE FIELDNAME(T) LIKE 'BO%')

works beautifully.

Thank you so much to everyone who helps.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Is there a way to find XML tag using wildcard ?
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.