DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10633>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10633

URI WhiteSpace Handling in xerces 2.02





------- Additional Comments From [EMAIL PROTECTED]  2002-09-27 05:25 -------
You can duplicate the problem with xerces samples.
Add xercesSsamples.jar to your classpath.

c:
cd c:\
mkdir "S ample"
copy anyvalidxmlfile.xml "S ample"
cd "S ample"
java dom/Counter anyvalidxmlfile.xml

--> And you get the error


You get this working if you do:
java dom/Counter "file:/S%20ample/anyvalidxmlfile.xml

But if you have xml schema with relative path in the file:
<xx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:noNamespaceSchemaLocation="anyvalidxmlfile.xsd"> -
then you again get errors when Xerces tries to read the schema file, 
because xerces itself inserts the home path to URI - and it contains blanks
- so its' a bug inside of xerces - if xerces wants to add a path to the URI - 
then it must itself take care that's it's a correct URI.



I did a dirty fix to XMLEntrityManagers fixURI method - now it changes spaces 
to 
%20. I believe it can be done with more elegant way than this, but I'm no Java 
expert...
After that everything seems to work correctly.

    protected static String fixURI(String str) {

        // handle platform dependent strings
        str = str.replace(java.io.File.separatorChar, '/');

        // Windows fix
        if (str.length() >= 2) {
            char ch1 = str.charAt(1);
            // change "C:blah" to "/C:blah"
            if (ch1 == ':') {
                char ch0 = Character.toUpperCase(str.charAt(0));
                if (ch0 >= 'A' && ch0 <= 'Z') {
                    str = "/" + str;
                }
            }
            // change "//blah" to "file://blah"
            else if (ch1 == '/' && str.charAt(0) == '/') {
                str = "file:" + str;
            }
        }
        String str2;
        str2 = "";
        for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == ' ') {
                 str2 = str2 + "%20";
            } else {
                     str2 = str2 + str.charAt(i);
                }
        }

        // done
        return str2;

    } // fixURI(String):String

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

Reply via email to