title: Running saxon xquery from Java program using net.sf.saxon.Query
body: <p>I am using Saxon 9.0.4 and included the Home Edition jar in my Eclipse project. But whenever I am issuing the query string, nothing is happening and I am not getting any output. When I am using the following command from the command line, I am getting the correct result:</p>
  
  <pre><code>java -cp saxon.jar net.sf.saxon.Query samplequery.xqy
  </code></pre>
  
  <p>Here is my query:</p>
  
  <pre><code>doc("rcmdemo5.xml")/book/chapter
  </code></pre>
  
  <p>And here is the code, I am using:</p>
  
  <pre><code>XQDataSource xqds = new SaxonXQDataSource();
  XQConnection conn = xqds.getConnection();
  XQExpression expr = conn.createExpression();
  String es = "doc(\"rcm.xml\")/book/chapter";
  XQResultSequence result = expr.executeQuery(es);
  while (result.next()) { 
      String str  = result.getAtomicValue();
      System.out.println("Product name: " + str);
  }
  result.close();
  expr.close();
  conn.close();
  </code></pre>
  
  <p>Where am I going wrong?
  Also, is it possible to get the input from a string instead of a file?</p>