File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

==> saxonb : but : RuntimeException: No query engine found

 
Aimee Best
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to use saxon to xquery an xml file with Java, below is the code just to give you an idea what I am trying to do (there is nothing wrong with it).

The thing is, if I try to run it, I get

Exception in thread "main" java.lang.RuntimeException: No query engine found
at org.apache.xmlbeans.impl.store.Query.getCompiledQuery(Query.java:160)
at org.apache.xmlbeans.impl.store.Query.getCompiledQuery(Query.java:85)
at org.apache.xmlbeans.impl.store.Query.cursorExecQuery(Query.java:80)
at org.apache.xmlbeans.impl.store.Cursor._execQuery(Cursor.java:1336)
at org.apache.xmlbeans.impl.store.Cursor._execQuery(Cursor.java:1331)
at org.apache.xmlbeans.impl.store.Cursor.execQuery(Cursor.java:3839)
at XMLBeansCursor.selectWithXQuery(TestXMLBeansCursor.java:40)
at TestXMLBeansCursor.main(TestXMLBeansCursor.java:106)


even though I have saxonb in the classpath

set cp=%classpath%;books.jar
set cp=%cp%;%saxon%\saxon9-dom4j.jar
set cp=%cp%;%saxon%\saxon9-jdom.jar
set cp=%cp%;%saxon%\saxon9-s9api.jar
set cp=%cp%;%saxon%\saxon9-sql.jar
set cp=%cp%;%saxon%\saxon9-xom.jar
set cp=%cp%;%saxon%\saxon9-xpath.jar
set cp=%cp%;%saxon%\saxon9-xqj.jar

java -cp %cp% TestXMLBeansCursor


The funny thing is, in eclipse this runs ok.

I can't see what's wrong, why does it work in eclipse but not on the command line?

Has anybody seen something like this before? Any ideas?

I am using java 6 update 18.

Thanks a lot in advance for any hints.


public void selectWithXQuery(File xmlFile) {
try {
InventoryDocument inventory =
InventoryDocument.Factory.parse(xmlFile);
XmlCursor cursor = inventory.newCursor();

String query =
"for $a in $this/inventory/book[1]"
+ "return $a/@author";

XmlCursor result = cursor.execQuery(query);
System.out.println(result.getObject().toString());

}
catch (IOException e){
e.printStackTrace();
}
catch (XmlException e){
e.printStackTrace();
}

} // end selectWithXQuery

 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps, contrary to what you think, Saxon is not in your classpath. I would review what's actually in that %saxon% variable, and also the list of Saxon jars which you have in your Eclipse build path compared to that list.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic