What version of the code are you working with – we have a test /xmlbeans/trunk/test/src/xmlcursor/xpath/complex/checkin/ContainerCommentTest.java that uses the $that variable and passes fine – I seem to remember there was a bug that was fixed a while ago regarding $that.

 

We currently do not type the result of XQuery – I think that will be hard to do but need to look into it further …If you need the result typed please open a bug and we’ll look into it more deeply. For now you can use .changeType to manually type the results:

 

XmlObject[] results =  o.execQuery(“…”);

MyType typedObj = (MyType) results[0].changeType ( MyType.type );

 

 

 


From: Guofeng Zhang [mailto:[EMAIL PROTECTED]
Sent: Monday, June 13, 2005 9:41 PM
To: [email protected]
Subject: selectPath and executeQuery: the result is different, why?

 

I use easypo sample to study how to use XPath to select XML according to the instruction in conSelectingXMLwithXQueryPathXPath.html

 

For the following query express,

        String pathText =xqNamesapce +  "$this//po:[EMAIL PROTECTED]'ss']";

        Customer[] customers = (Customer[])poDoc.selectPath( queryText ) ;

I got the following exception:

java.lang.RuntimeException: net.sf.saxon.xpath.StaticError: XPath syntax error at char 5 in {$this//po:customer}:

Variable $this has not been declared

 

If I change the express to (replace “$this” with “.”):

        String pathText =xqNamesapce +  ".//po:[EMAIL PROTECTED]'ss']";

The code works well.

 

If I use executeQuery() instead of selectPaht(), I find that I have to use “$$this” or “.” to replace “$this” in the above pathText string, or no result is found. I also find that the return type of the executeQuery() is XmlAnyTypeImpl, instead of CustomerImpl.

 

I do not know if I configure my runtime environment incorrectly or I misunderstand the content in conSelectingXMLwithXQueryPathXPath.html?

 

Thanks for your help very much.

 

Guofeng

 

 

 

--------------------------------------------------------------------------------

Join CEO Alfred Chuang and CTO Mark Carges on June 15 for a unique online 
event, giving you the first look at a new category of enterprise software 
built specifically for Service-Oriented Architecture (SOA).

Register Now.  It's Free!

http://www.bea.com/events/june15

Reply via email to