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 » No result from evaluateXPath

Post new topic  Reply to topic
 No result from evaluateXPath « View previous topic :: View next topic » 
Author Message
Seb
PostPosted: Sun Jan 23, 2011 1:25 am    Post subject: No result from evaluateXPath Reply with quote

Apprentice

Joined: 27 Mar 2009
Posts: 41

Hi,

I am opening this topic for one of our developers, who is struggling with the evaluateXPath function. However, using XMLSpy it seems to be valid v1.0 statement.

This is an exemplary message:

Code:
<Element01>
   <Element02>
      <Element03>sun</Element03>
      <Element04>
         <Element05>hello</Element05>
      </Element04>
   </Element02>
   <Element02>
      <Element03>rain</Element03>
      <Element04>
         <Element05>good bye</Element05>
      </Element04>
   </Element02>
</Element01>


He tries to first test the value of a child element before he gets the value of the ancestor:

/Element01/Element02/Element04/Element05[text() = 'hello']/parent::node()/parent::node()/Element03

I couldn't see anything wrong or a way of reconstructing the statement. Hope someone can help.

Thanks,
Seb
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Sun Jan 23, 2011 7:22 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

I'm not entirely sure that text() is the right thing to get the value of the element. But I've not double-checked that intuition against the Broker XPath documentation.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Sun Jan 23, 2011 8:58 am    Post subject: Re: No result from evaluateXPath Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Seb wrote:
Code:
/Element01/Element02/Element04/Element05[text() = 'hello']/parent::node()/parent::node()/Element03

XPath models an XML document as a tree of XML nodes; text nodes are always children of element nodes. MbXPath operates against a tree of MbElements; whether text nodes are children of element nodes depends on the tree structure. A Trace node would illustrate the tree structure.

Compare this:
Code:
/*  XPath: ".../Element05[text()='hello']/..."  */

    MbElement(type=TYPE_NAME, name="Element05")
       MbElement(type=TYPE_VALUE, value="hello")

with this:
Code:
/*  XPath: ".../Element05[self::node()='hello']/..."  */

    MbElement(type=TYPE_NAME_VALUE, name="Element05", value="hello")


For the second example, the complete XPath expression would be:
Code:
/Element01/Element02/Element04/Element05[self::node()='hello']/parent::node()/parent::node()/Element03

or abbreviated:
Code:
/Element01/Element02/Element04/Element05[.='hello']/../../Element03

or refactored:
Code:
/Element01/Element02[Element04/Element05='hello']/Element03
Back to top
View user's profile Send private message
Esa
PostPosted: Sun Jan 23, 2011 9:04 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Regardles of if the syntax of the xsl sample is right or wrong, you get no results because it is pointing to a nonexistent element.

/Element01/Element02 does not have a child called Element03.
Back to top
View user's profile Send private message
Esa
PostPosted: Sun Jan 23, 2011 9:06 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Yes it has. I need new glasses.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Sun Jan 23, 2011 6:58 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Esa wrote:
Regardless of if the syntax of the xsl sample ...

Typo? On a side note, XSL Transformations supports a subset of XPath expressions as matching patterns, allowing only child and attribute axis specifiers. "parent::node()" would not be part of a valid XSLT matching pattern.
Back to top
View user's profile Send private message
bsiggers
PostPosted: Mon Jan 24, 2011 8:57 am    Post subject: Isolation? Reply with quote

Acolyte

Joined: 09 Dec 2010
Posts: 53
Location: Vancouver, BC

You may want to test your XML and XPATH outside of broker - there are lots of interactive tools online if you don't happen to have something like XMLSpy.

http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm

This way you can isolate if it's an XPATH expression issue or something wrong in the way that you're working with/interpreting the results.
Back to top
View user's profile Send private message
Seb
PostPosted: Thu Jan 27, 2011 3:59 pm    Post subject: Reply with quote

Apprentice

Joined: 27 Mar 2009
Posts: 41

Hi,

just want to say thanks!

rekarm01's solution worked with a couple of slight modifications due to our more complex IFW XML structures.

@bsiggers: That was the weird thing, the developer was actually constructing the xpath statements in XML Spy and they worked fine, but WMB didn't get to the same result.

Anyway, problem solved and I learned how to better construct the xpath statements as well.

Thanks again,
Seb
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » No result from evaluateXPath
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.