You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Berin Loritsch <bl...@apache.org> on 2001/07/11 20:44:25 UTC

URL Bug

I found out while debugging the XIncludeTransformer that the construct

new URL(baseUrl, relative);

does not return the expected results--esp. when dealing with "file"
URLs.

if your baseUrl variable is set to "file:C:\pat\to\context\" (what happens
when you transform a "context" url through the factory first), when you
try to get a relative URL to that one you lose everything about the base
URL.

------------------- Example --------------------

URL baseUrl = new URL("file:C:\\path\\to\\context\\");
String relative = "index.xml";

URL newUrl = new URL(baseUrl, relative);

System.out.println(newUrl.toExternalForm());

------------------- Results --------------------

file:index.xml

--------------- Expected Results ---------------

file:C:\path\to\context\index.xml

--------------------- End ----------------------


I fixed the URLFactoryImpl class to work around this
with "file" protocol URLs.  This way the XIncludeTransformer
can work as expected.  I assume this is a bug in Sun's JVM,
but I am not the only one bitten by it.

Does anyone else have input on this?

IMPORTANT
Please note that the XIncludeTransformer's namespace has been
upgraded to the currently released spec as well.