text file path different from working direct.
Added by Anonymous over 15 years ago
Legacy ID: #7452397 Legacy Poster: perl0101 (perl0101)
Hello everyone, I want to use SAXON to transform a collection of text files stored in a directory into a collection of XML files. Now I am using Java to call saxon9-s9api to process each file in the collection. I already have one stylesheet which accepts one text file as the value of a parameter used in the stylesheet. The problem I have is that the path of text files are different from the working directory in Eclipse. So the input text files can not be read. My question is how to solve it? I have look though previous posts and found some people use doc() or collection() to do it. I would like to get more information about it. Thanks in advance.
Replies (5)
Please register to reply
RE: text file path different from working direct. - Added by Anonymous over 15 years ago
Legacy ID: #7453618 Legacy Poster: perl0101 (perl0101)
Hello, Good morning. If someone here who knows the solution to my problem, please give me some clues. Thanks.
RE: text file path different from working direct. - Added by Anonymous over 15 years ago
Legacy ID: #7453625 Legacy Poster: David Lee (daldei)
The very simpliest way is to change the working directory in eclipse. In the Run Dialog there is a setting for the working directory. When run standalone as a java app, just do a "cd" prior to running your java program. There are of course other ways to do it but you havent provided enough detail for me to suggest anything constructive.
RE: text file path different from working direct. - Added by Anonymous over 15 years ago
Legacy ID: #7453660 Legacy Poster: perl0101 (perl0101)
Hello, When the working directory is set to the path of the text files directory and run the SAXON standalone, it works fine. What I want to do is to use SAXON to transform and pass the generated XML files to another Java application. When I set the working directory to be different from text files, the program can not find the files to read. working directory = "d:\Saxon\history; In my code, String sourceFileName="d:\Saxon\..\sources\"; The error message is as follows: Source file d:\Saxon\stockHistory..\sources does not exist. Thanks for your explanation.
RE: text file path different from working direct. - Added by Anonymous over 15 years ago
Legacy ID: #7455536 Legacy Poster: Michael Kay (mhkay)
You haven't been very explicit about what you are doing. What exactly are you passing in the parameter to the stylesheet, and what exactly is the stylesheet doing with the value? If you are passing a relative file name, and then reading the file using the unparsed-text() function, the unparsed-text() function is defined to interpret the file name (or URI) as relative to the base URI of the stylesheet, not the current working directory of the application. It's probably better to pass an absolute URI as the parameter from your application.
RE: text file path different from working direct. - Added by Anonymous over 15 years ago
Legacy ID: #7456292 Legacy Poster: perl0101 (perl0101)
I pass an absolute URI as the parameter and it works. Thanks for your suggestion. have a nice day.
Please register to reply