Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.6.2
-
None
-
None
-
1. Custom protocol and the java.protocol.handler.pkgs System property set
to recognize that protocol.
2. Running Sun JDK 1.4.2_04
3. Xerces 2.6.2 initially,
xercesImpl-gump-03032005.jar for last minute check.
Description
Error calcuating the Base URI for XML included through the XInclude process.
I did not see a way to use existing tests to illustrate this problem so I
zipped up a standalone test.
Problem:
---------
TESTING CONDITIONS:
Root document
error.test://dogs/DogRoot.xml
XIncludes
error.test://cats/Noise.xml
which XIncludes
error.test://dogs/Noise.xml
When the XIncludeHandler.getRelativeBaseURI() method calculates the relative
Base URI
relativeURI = error.test://dogs/Noise.xml
fParentRelativeURI = error.test://cats/Noise.xml
it assumes it is a file: protocol.
URI uri = new URI("file", error.test://cats/Noise.xml);
The PATH of the the uri then equals
error.test://cats/Noise.xml
The URI is then resolved against the URI specification string
error.test://dogs/Noise.xml
uri = new URI(uri, error.test://dogs/Noise.xml);
Resulting in the relative path
/Noise.xml
return uri.getPath();
Since parent was //cats/Noise.xml the /Noise.xml could be seen as //cats/Noise.xml
This is incorrect because error test://dogs/Noise.xml
is a different file than error test://cats/Noise.xml
Solution:
---------
Remove hard coded file scheme. Return path is the scheme and
authority are the same, otherwise return the relative path.
URI uriParent = new URI(fParentRelativeURI);
URI uriChild = new URI(uriParent, relativeURI);
if (!uriChild.getHost().equals(uriParent.getHost())
!uriChild.getScheme().equals(uriParent.getScheme()))
{
return relativeURI;
}
return uriChild.getPath(); |
---|
In the above test the relativeURI value (error.test://dogs/Noise.xml) would
be returned, since the authority dogs does not equal cats.