Michael wrote:

> I know this topic has been very often discussed. But I haven't found
> any help on this in the FAQ.
> 
> I know, you have to encode the filename, in order to get this work.
> What I want to know is: is there any sample mehtod to perform this
> conversion? java.net.URLEncoder.encode() will not work, since it
> translates ' ' into '+'.
> 
> Another thing, which I don't like in this context is the Constructor
>    javax.xml.transform.stream.StreamSource(java.io.File�f)
> which I use for creating an XSLT Transformer.
> Here you have a File for the constructor, and when this File-object
> is a file containing a space, you run into the MalformedUrlException
> when you use xerces as parser.
> I actually dislike the idea of using an encoded-File-object.
> Perhaps this constructor should be deprecated, and instead one
> should use the constructorwhich takes a SystemID? Or better:
> shouldn't the 'File'-Constructor perform this encoding?
> 
> I just saw "public Document DocumentBuilder.parse(File f)". You
> probably have the same problem here too.

Not sure about JAXP transform APIs but this was fixed for Parser APIs.
So, there should not be any problem when you are using .parse(File f)
JAXP takes care of any file object representing path containing spaces.


> So what is the right way to parse a file using jaxp so all parsers can
> handle all files? 

If JAXP APIs doesn't accept any file object containing spaces then it should be 
fixed. BTW, what version of Xerces are u using ?

>And can anybody give an example of a (fully) working
> File->systemID converter?

You might want to have a look at javax.xml.parsers.ConvertToURI or 
javax.xml.parsers.FilePathToURI. For your purpose, both does the same thing.
But FilePathToURI also takes care of non-ASCII character.

If you are using JDK1.4, you can also use toURI() function of java.io.File 
object.


Neeraj


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to