Project

Profile

Help

File not found error

Added by Anonymous over 15 years ago

Legacy ID: #7455366 Legacy Poster: perl0101 (perl0101)

Hello, I want to pass a text file to a parameter declared in an xslt. Here is my code: URI uri = new URI("file:///d:/Saxon/sources/"); sourceFile = new File(uri); if (sourceFile.isDirectory()) { String[] files = sourceFile.list(); for (int f = 0; f < files.length; f++) { File s = new File(files[f]); t.setParameter(paramName, new XdmAtomicValue(s.getName())); t.setDestination(out); t.transform(); } } But I get an error and the erro message is the following: Caused by: net.sf.saxon.trans.XPathException: java.io.FileNotFoundException: D:\Saxon\stockHistory\A.h60 (The system cannot find the file specified) at net.sf.saxon.trans.StandardUnparsedTextResolver.resolve(StandardUnparsedTextResolver.java:167) at net.sf.saxon.functions.UnparsedText.readFile(UnparsedText.java:128) at net.sf.saxon.functions.UnparsedText.evaluateItem(UnparsedText.java:78) at net.sf.saxon.expr.Expression.iterate(Expression.java:370) at net.sf.saxon.expr.ExpressionTool.evaluate(ExpressionTool.java:308) I wish someone here can help me identify the problem. thanks in advance.


Replies (2)

RE: File not found error - Added by Anonymous over 15 years ago

Legacy ID: #7455506 Legacy Poster: Michael Kay (mhkay)

File.getName() returns the last component of the hierarchic name. For example if the file is c:/temp/a.txt then it returns "a.txt". So the unparsed-text() function will look for a.txt in the directory that holds the stylesheet, not in c:/temp. I would suggest t.setParameter(paramName, new XdmAtomicValue(s.toURI().toString()));

RE: File not found error - Added by Anonymous over 15 years ago

Legacy ID: #7456300 Legacy Poster: perl0101 (perl0101)

Thanks. It works by passing an absolute URI.

    (1-2/2)

    Please register to reply