You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "s.k.i." <sy...@gmail.com> on 2008/08/30 18:49:50 UTC

XmlBeans with XQuery Troubles

 I am having difficulty getting selectPath() and executeQuery() to work on a
very simple xml example.

The following small example sums up my problem.

In the following code, I would expect 'result = test' to print.

	  
		String doc = " <test/> ";
	        query = "/a/test";
	        try{
	           XmlObject xml = XmlObject.Factory.parse(doc);
	           XmlCursor cursor = xml.newCursor();
	           cursor.push();
	           cursor.selectPath(query);
	           System.out.println("result = " +cursor.getTextValue());
	         }catch(Exception e){
	        	 System.out.println(e.getMessage());
	         }
	         

However, 'result =' indicating that selectPath() returns nothing.

My runtime classpath  contains the following xmlbeans and saxon related
entries:
xbean.jar
jsr173_1.0_api.jar
xbean-xpath.jar
saxon9.jar
saxon9-xqj.jar
saxon9-dom.jar

xmlbeans version is 2.4
saxon version is 9.0.0.4j

Can someone give me some pointers as to what I may have done wrong or how I
should go about resolving this issue?
Thanks,
ski
-- 
View this message in context: http://www.nabble.com/XmlBeans-with-XQuery-Troubles-tp19235072p19235072.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: XmlBeans with XQuery Troubles

Posted by Eric Murphy <er...@shaw.ca>.
Ski 

I don't see a namespace declaration in your xpath query. As far as I know
you need to add this declaration for any namespaces that may be part of the
query path. After the namespace declaration comes your query. Here is an
example that includes two namespaces:

declare namespace m='http://eric.org/xml/baseData' declare namespace
y='http://eric.org/xml/data';
$this/y:athlete_list/y:athlete/m:person[@id='eotgpe']

The above string is the argument that I must supply to selectPath(String) to
execute the query. Notice you also need the namespace declarations before
the element names. 

I am not sure if there is any other way to do this. I have tried a number of
variations but this is the only technique I have successfully used.

Eric

-----Original Message-----
From: s.k.i. [mailto:sylvia.isler@gmail.com] 
Sent: Saturday, August 30, 2008 9:50 AM
To: user@xmlbeans.apache.org
Subject: XmlBeans with XQuery Troubles


 I am having difficulty getting selectPath() and executeQuery() to work on a
very simple xml example.

The following small example sums up my problem.

In the following code, I would expect 'result = test' to print.

	  
		String doc = " <test/> ";
	        query = "/a/test";
	        try{
	           XmlObject xml = XmlObject.Factory.parse(doc);
	           XmlCursor cursor = xml.newCursor();
	           cursor.push();
	           cursor.selectPath(query);
	           System.out.println("result = " +cursor.getTextValue());
	         }catch(Exception e){
	        	 System.out.println(e.getMessage());
	         }
	         

However, 'result =' indicating that selectPath() returns nothing.

My runtime classpath  contains the following xmlbeans and saxon related
entries:
xbean.jar
jsr173_1.0_api.jar
xbean-xpath.jar
saxon9.jar
saxon9-xqj.jar
saxon9-dom.jar

xmlbeans version is 2.4
saxon version is 9.0.0.4j

Can someone give me some pointers as to what I may have done wrong or how I
should go about resolving this issue?
Thanks,
ski
-- 
View this message in context:
http://www.nabble.com/XmlBeans-with-XQuery-Troubles-tp19235072p19235072.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org