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 » Wildcards in ESQL?

Post new topic  Reply to topic
 Wildcards in ESQL? « View previous topic :: View next topic » 
Author Message
Brian1973
PostPosted: Mon Oct 29, 2012 8:49 am    Post subject: Wildcards in ESQL? Reply with quote

Newbie

Joined: 29 Oct 2012
Posts: 4

Hopefully this is an easy question, I accept all deserved NOOB ridicule if you just nudge me in the correct direction.

WMB 6.1


I am using this code to reference a certain field in the message:
Code:
InputRoot.XMLNSC.EventTransaction.*:ItemData.ABCDocs.RouteFlag

This works fine. The problem is that sometimes the message is different and it has XYZDocs instead of ABCDocs as the element name. The RouteFlag stays the same. There might be other names for this element other than the 2 listed as well.

RouteFlag is an attribute of ABCDocs or XYZDocs or whatever else comes along.

The pseudocode would be something like this, but this doesn’t actually work:
Code:
InputRoot.XMLNSC.EventTransaction.*:ItemData. *.RouteFlag


How do I make this generic enough to accept anything there? I need the RouteFlag, that is the only important field. I feel like I have tried many combinations of "*" ":" etc and nothing works.


Code:
In XSLT this code does what I want. 
    <xsl:if test="($routeFlag != 'Y')">
            <xsl:message terminate="yes">Error=003:RouteFlag is not Y</xsl:message>
    </xsl:if> 



Thanks very much for your help.
Brian
Back to top
View user's profile Send private message
McueMart
PostPosted: Mon Oct 29, 2012 9:02 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

I would have expected this to work...

Code:
InputRoot.XMLNSC.EventTransaction.*:ItemData.*.(XMLNSC.Attribute)RouteFlag
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Oct 29, 2012 9:32 am    Post subject: Reply with quote

Grand High Poobah

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

McueMart wrote:
I would have expected this to work...

Code:
InputRoot.XMLNSC.EventTransaction.*:ItemData.*.(XMLNSC.Attribute)RouteFlag


I wouldn't, though I've been wrong before.

A simple solution would be:

Code:
InputRoot.XMLNSC.EventTransaction.*:ItemData.[1].(XMLNSC.Attribute)RouteFlag


Where [1] becomes whichever poisition the tag is in.

A more sophisticated solution would be something like this untested snippet:

Code:
THE(SELECT E.RouteFlag FROM InputRoot.XMLNSC.EventTransaction.*:ItemData.[]


for those situations where RouteFlag can be anywhere.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Brian1973
PostPosted: Mon Oct 29, 2012 9:33 am    Post subject: Reply with quote

Newbie

Joined: 29 Oct 2012
Posts: 4

Thank you for your suggestion. I am sure this is the right direction but still doesn't work with the element name wildcard.


Code:
WORKS - SET RouteFlag2 = FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.ABCDocs.(XMLNSC.Attribute)RouteFlag);      

DOES NOT WORK - SET RouteFlag  = FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.*.(XMLNSC.Attribute)RouteFlag);      
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Oct 29, 2012 9:48 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Use a reference. YOu can then go to the first child, next sibling etc...
You can also read the tagname by using fieldname and fieldnamespace functions...
Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mgk
PostPosted: Mon Oct 29, 2012 9:49 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Can you post a larger section of your input message, as that may help see what is happening. My guess is that ABCDocs is not the FirstChild of ItemData. In this case you need to know that the '*' does not mean "search all child elements" to find one with the RouteFlag, it actually means "go to the first element, whatever its name." So you may need to use:

Code:
InputRoot.XMLNSC.EventTransaction.*:ItemData.*[2].(XMLNSC.Attribute)RouteFlag


if ABCDocs is the second element, *[3] if it is the third etc.


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
fjb_saper
PostPosted: Mon Oct 29, 2012 9:54 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

I'd do it with a reference walking through the siblings. If the fieldname has a pattern (ending in Docs for instance) it should be relatively easy to pick the right children / siblings...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Mon Oct 29, 2012 10:02 am    Post subject: Re: Wildcards in ESQL? Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Brian1973 wrote:
The pseudocode would be something like this, but this doesn’t actually work:
Code:
InputRoot.XMLNSC.EventTransaction.*:ItemData. *.RouteFlag

There seems to be an extra space in the ESQL reference; that might just be a posting error, but it won't work in the code.

If the wildcard matches more than one element, then that can cause problems; adding an index can help. (For example: ... .ItemData.*[<]. ...) The InfoCenter explains ESQL support for wildcards in more detail. A Trace node can provide the actual message tree structure, and a debug-level usertrace can show exactly how the message flow is resolving the ESQL reference.
Back to top
View user's profile Send private message
Brian1973
PostPosted: Mon Oct 29, 2012 11:31 am    Post subject: Reply with quote

Newbie

Joined: 29 Oct 2012
Posts: 4

This works, thanks a lot everyone.

Code:
FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.[4].(XMLNSC.Attribute)RouteFlag);


Thanks for the info center link. The XSLT I posted will look for RouteFlag anywhere in the document. I will try out the SELECT .... statement as well.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Mon Oct 29, 2012 1:57 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Brian1973 wrote:
This works, thanks a lot everyone.

Code:
FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.[4].(XMLNSC.Attribute)RouteFlag);

Really? That looks like a syntax error, due to a missing '*' or resolved name:

Code:
FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.*[4].(XMLNSC.Attribute)RouteFlag);

If it works without the extra '*', then the documentation needs updating.

Brian1973 wrote:
The XSLT I posted will look for RouteFlag anywhere in the document.

The posted portion of the XSLT doesn't actually do that.
Back to top
View user's profile Send private message
McueMart
PostPosted: Tue Oct 30, 2012 1:14 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

Quote:
. In this case you need to know that the '*' does not mean "search all child elements" to find one with the RouteFlag, it actually means "go to the first element, whatever its name."


Interesting stuff - thanks for the clarification. What confused me a tad was the infocenter:

Quote:
You can use the asterisk (*) wildcard character in a path element to match any name. For example:

InputRoot.XMLNS.*.Invoice.Value

matches any path element in which the invoices are contained.

(http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/ak04861_.htm?resultof=%22xmlnsc%22%20%22wildcard%22)

I might just be interpreting that wrong!
Back to top
View user's profile Send private message
Brian1973
PostPosted: Tue Oct 30, 2012 6:44 am    Post subject: Reply with quote

Newbie

Joined: 29 Oct 2012
Posts: 4

both of these work, i don't understand the difference between the two.


Code:
FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.[4].(XMLNSC.Attribute)RouteFlag);

FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.*[4].(XMLNSC.Attribute)RouteFlag);
Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri Nov 02, 2012 1:03 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Brian1973 wrote:
both of these work, i don't understand the difference between the two.

Code:
FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.[4].(XMLNSC.Attribute)RouteFlag);

FIELDVALUE(InputRoot.XMLNSC.EventTransaction.*:ItemData.*[4].(XMLNSC.Attribute)RouteFlag);

The difference is that one of these is documented, and the other is not. If the first form happens to work without generating a syntax error, then that's a (happy?) accident, but it may suddenly stop working at some point in the future. That's less likely to happen with the second form.
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 » Wildcards in ESQL?
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.