The import statements should be of the form
 
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.query.DynamicQueryContext;
etc.
 
Check the sample applications provided (in the saxon-resources8.n download) and use them as a starting point.
 
Using an IDE like IntelliJ can be very helpful because it will generate the import declarations automatically.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of enis enis
Sent: 01 October 2006 15:54
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Testing XQuery with JAVA

 I want to test a the execution of a query with java using XQuery. This is the class but I have some errors saying that alla the classes imported don't exist, even though all the saxon directory is in the classpath !!

import NodeInfo.java;
import DynamicQueryContext.java;
import StaticQueryContext.java;
import XQueryExpression.java;
import XPathException.java;

public class Xquery {
public static void main(String[] args) {
Configuration conf = new Configuration();
StaticQueryContext staticContext = new StaticQueryContext(conf);

String query = "for $q in (<Root> <Hello>Hi! "
          + "</Hello>   <Name>Nice</Name>   </Root>) "
          + "return <HelloExample>{xs:string($q/Hello)} "
          + "{xs:string($q/Name)}</HelloExample> ";

QueryProcessor qp = new QueryProcessor(conf, staticContext);
try {
      XQueryExpression xqe = staticContext.compileQuery(query);
      DynamicQueryContext dc = new DynamicQueryContext(conf);
      NodeInfo ob = (NodeInfo) xqe.evaluateSingle(dc);
          
      System.out.print(ob.getRoot());
      // It prints Hi! Nice in console
     } catch (XPathException e) {
      e.printStackTrace();
     }
}