What is the text of your query, that is, the contents of
c:\dev\ftp\data\filter.xq? In particular, does it call the doc()
A problem with passing a FileInputStream to Saxon is that
Saxon doesn't know which file it is reading from, therefore the associated
query or XML document has no usable base URI. In such cases Saxon interprets
relative URIs as being relative to the current directory. It's always better to
establish an explicit base URI. For an XML document you can do this using the
third argument of bindDocument() (which you have set to null); for the query,
you can do it by passing an XQStaticContext (on which you have first called
setBaseURI()) as the second argument of prepareExpression(). This should only
matter if your query contains a call to doc('feed.xml') - but my guess is that
Incidentally, the whole point of the XQJ interface is that
it's a standard API that should work with multiple XQuery implementations. So
your application should be using the interface names (XQDataSource), not the
Saxon implementation class names (SaxonXQDataSource). If you're going to call
Saxon-specific interfaces, I would suggest using the s9api interface instead as
it's a much better fit to Saxon's overall architecture.
I am getting a FileNotFoundException when trying to execute query
for a prepared expression. The core code looks like the
= new SaxonXQDataSource();
prop = new
prop.setProperty( "method", "xml"
prop.setProperty( "indent", "yes"
File filDoc = new
File( "C:\\dev\\ftp\\data\\feed.xml" );
filXqj = new File(
fisDoc = new
FileInputStream( filDoc );
fisXqj = new
(SaxonXQPreparedExpression) conn.prepareExpression( fisXqj
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.