You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Guofeng Zhang <gu...@radvision.com> on 2005/06/14 06:41:19 UTC

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:customer[@nx='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:customer[@nx='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