You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Owen Chang (JIRA)" <xa...@xml.apache.org> on 2009/11/20 08:00:39 UTC
[jira] Created: (XALANJ-2511) Transformer failed to transform
DomSource to StreamResult, if the StreamResult is created with a File and
the file name contain space charactor
Transformer failed to transform DomSource to StreamResult, if the StreamResult is created with a File and the file name contain space charactor
-----------------------------------------------------------------------------------------------------------------------------------------------
Key: XALANJ-2511
URL: https://issues.apache.org/jira/browse/XALANJ-2511
Project: XalanJ2
Issue Type: Bug
Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
Components: Serialization
Affects Versions: 2.7.1
Environment: Windows Server 2003
Reporter: Owen Chang
Problem:
I use the transformer to write a dom document to a file, so I use a DOMSource, and a StreamResult. I create a Stream Result using the contructor:
public StreamResult(File f)
and the file path I used includes space charactor, like "E:\Program Files\XXXX.xsd", and I run it, the error occurs:
java.io.FileNotFoundException: E:\Program%20Files\XXXX.xsd
Analysis:
When I create the StreamResult, the constructor call its setSystemId method, in that method, the file path is converted to a URI, the code like this:
this.systemId = f.toURI().toString();
So, The systemId stored in StreamResult is like:
file:\\\E:\Program%20Files\XXXX.xsd
But in the TransformerIdentityImpl(org.apache.xalan.transformer)'s createResultContentHandler method, it convert the uri to filepath and use FileOutputStream to open the file. The convert logic is as following:
String fileURL = sresult.getSystemId();
if (fileURL.startsWith("file:///")) {
if (fileURL.substring(8).indexOf(":") >0) {
fileURL = fileURL.substring(8);
} else {
fileURL = fileURL.substring(7);
}
} else if (fileURL.startsWith("file:/")) {
if (fileURL.substring(6).indexOf(":") >0) {
fileURL = fileURL.substring(6);
} else {
fileURL = fileURL.substring(5);
}
}
The problem is that it does not decode the %20 charactor to space charactor.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org