Project

Profile

Help

Spaces in output path (Saxon 6.5.4, Java 5)

Added by Anonymous about 19 years ago

Legacy ID: #3243797 Legacy Poster: Kevin Yank (kyank)

When I run Saxon 6.5.4 from the command line, any spaces in the output path are getting converted to %20. For example, in C:\Sample Directory, if I run this command: java -jar "C:\Program Files\Saxon\Saxon.jar" -o out.xml in.xml style.xsl out.xml gets created in C:\Sample%20Directory instead of C:\Sample Directory. This problem only occurs with Saxon running under Java 5. If I roll back to Java 1.4, the problem goes away. How can I get it to work right with Java 5?


Replies (1)

RE: Spaces in output path (Saxon 6.5.4, Java - Added by Anonymous about 19 years ago

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

What appears to have happened here is that Java 5 (or more specifically, JAXP 1.3) has fixed a long-standing bug in its file-to-URI conversion, so that the file name "c:\test dir\test.out" is now converted correctly to the URI "file:/test%dir/test.out" Unfortunately, the constructor "new File(uri)" to do the reverse conversion was introduced only in JDK 1.4, so Saxon 6.5.x still uses a hand-crafted routine which doesn't unescape the % signs. (In other words, Saxon was relying on the bug in previous JAXP releases remaining present.) The routine in question (the code is borrowed from Xalan, and is quite appalling) is method urlToFileName() in module GeneralOutputter. It's not easy to see how to fix this. Under JDK 1.4 or later, we could replace this routine with public static String urlToFileName(String base) { return new File(new URI(base)).toString(); } with some suitable exception handling. But we have to support JDK 1.2 and later, which would seem to mean patching up this horrible method to do the job a bit more thoroughly - not an attractive prospect, given that the escaped %HH characters have to be decoded from UTF-8. I'm afraid this is going to become simply a documented restriction. (It applies equally to 6.5.3 and 6.5.4, by the way, but works fine in 8.x). Michael Kay

    (1-1/1)

    Please register to reply