FileNotFoundException

2008-10-14
2012-10-08
  • Steven Dahlin
    Steven Dahlin
    2008-10-14

    am getting a FileNotFoundException when trying to execute query for a prepared expression. The core code looks like the following:

    SaxonXQDataSource ds = new SaxonXQDataSource();
    SaxonXQConnection conn = (SaxonXQConnection) ds.getConnection();
    java.util.Properties prop = new Properties();

    prop.setProperty( "method", "xml" );
    prop.setProperty( "indent", "yes" );

    File filDoc = new File( "C:\dev\ftp\data\feed.xml" );
    File filXqj = new File( "C:\dev\ftp\data\filter.xq" );

    FileInputStream fisDoc = new FileInputStream( filDoc );
    FileInputStream fisXqj = new FileInputStream( filXqj );

    SaxonXQPreparedExpression exp = (SaxonXQPreparedExpression) conn.prepareExpression( fisXqj );

    exp.bindDocument( XQConstants.CONTEXT_ITEM,
    (InputStream) fisDoc,
    null,
    null );

    xqResult = exp.executeQuery();

    When it runs the executeQuery() it errors with the exception indicating that it cannot find the xml file: "C:\dev\ftp\feed.xml"! Somehow it wants to find the feed.xml in the parent directory of where it actually is. I should mention that I think the java app is actually executed from the "C:\dev\ftp" directory but I made sure that the File object does indeed point to C:\dev\ftp\data\feed.xml" and that the FileInputStream object can read which is the case up until I execute the bindDocument() function with the expression. After the bindDocument() is executed that is when the error occurs.

     
    • Michael Kay
      Michael Kay
      2008-10-14

      You raised the same question on the saxon-help mailing list, I'll deal with it there. (For anyone looking for the archives, go to http://saxon.markmail.org/ and search there).