Error calcuating the Base URI for XML included through the XInclude process.
----------------------------------------------------------------------------
Key: XERCESJ-1047
URL: http://issues.apache.org/jira/browse/XERCESJ-1047
Project: Xerces2-J
Type: Bug
Components: XInclude 1.0
Versions: 2.6.2
Environment: 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.
Reporter: Cindy Moncsko
Attachments: TestBaseUri.zip, xercesCustomProtocolBaseUriPatch.txt
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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]