|
Guofeng, My aplogies – I spoke too soon – it appeared to me that you
can type the result yourself but I’m wrong. I’ll investigate if
there is a workaround on this, for now, consider that you can’t type the
result. P.S. The only supported version is saxon8.1.1, so no wonder saxon8-2
gives you that error. From: Guofeng
Zhang [mailto:[EMAIL PROTECTED] My environment: xmlbeans-2.0.0-beta1, saxonb8-1-1, JDK
1.5.0. The following code is changed according to
your instruction:
String nsText = "declare namespace po =
'http://openuri.org/easypo';";
String pathText = ".//po:[EMAIL PROTECTED]'ss']";
String queryText = nsText + pathText;
XmlObject[] customers = (XmlObject[])poDoc.execQuery( queryText ) ;
for ( int i = 0 ; i < customers.length ; i++ )
{
Customer typedObj = (Customer) customers[0].changeType ( Customer.type );
System.out.println( "Customer address: " + typedObj.getAddress() ) ;
} The address returned is null. I find that for saxonb8-2, if I use
selectPath() in the above code, the code throws “Exception in thread
"main" java.lang.NoSuchMethodError:
net.sf.saxon.xpath.XPathEvaluator.setStaticContext(Lnet/sf/saxon/expr/StaticContext;)V”
but for saxonb8-1-1, it works well. If I use saxon saxonb8-4, the code throws
“java.lang.RuntimeException: No query engine found”. Thanks for your help. Guofeng From: Yana
Kadiyska [mailto:[EMAIL PROTECTED] 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] 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 |
- selectPath and executeQuery: the result is different, why? Guofeng Zhang
- RE: selectPath and executeQuery: the result is differen... Yana Kadiyska
- RE: selectPath and executeQuery: the result is differen... Guofeng Zhang
- RE: selectPath and executeQuery: the result is differen... Yana Kadiyska
- RE: selectPath and executeQuery: the result is differen... Guofeng Zhang

