cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
Subject [proposal] some changes to SourceResolver.resolve(baseURI, location, params)
Date Sun, 25 May 2003 18:37:12 GMT
Hi,

you may or may not have noticed some discussing going on about relative
to absolute URL resolving, i.e. making an absolute URL based on a
baseURI and some location (lets call this process "absolutizing"). This
mostly happend in bug 20088 [1].

The conclusion was that since the format of the URL data following the
scheme name is scheme specific, it is only the implementation of the
Source(Factory) that can rightfully know if and how relative URL
resolving is possible. See also the problem with the cocoon and context
schemes where the authority part is actually a part of the path.

Therefore, I propose to move the absolutizing code out of
SourceResolverImpl.resolveURI(location, baseURI, params) and into a new
method SourceFactory.resolveURI(location, baseURI, params), to be
implemented by each source factory. The method
SourceResolver.resolveURI(...) will continue to exist, but will now have
more of a dispatch function (see below).

Additionally, the current implementation of the SourceResolverImpl does
not do the absolutizing very well. For example, given the location
"../otherfile.xml" and the baseURI
"http://localhost:8080/dir1/dir/file.xml", it will absolutize this to
"http://localhost:8080/dir1/dir/file.xml/../otherfile.xml".

I have already the utility code ready to do correct absolutizing both
for "normal" URLs and for the cocoon and context cases, so it is mainly
a matter of integrating it into the current sourceresolver.

The new algorithm for SourceResolverImpl.resolve would become:

Given the input parameters baseURI and location:

0. special file trickery: (as done in the current implementation)
   if location.charAt(1) == ':"
     then location = "file:/" + location
   if (location.charAt(0) == '/' and location.charAt(2) == ':')
     then location = "file:" + location

1. determine scheme:
     - if the scheme of the location is not empty, use that
     - otherwise use the scheme of the baseURI (it is an error
       for baseURI not to have a scheme)

2. use the scheme to lookup the SourceFactory

3. do SourceFactory.createSource(location, baseURI, params)

Thoughts? Everyone ok with this?

[1] http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20088

PS: thanks to Torsten K. to keep the discussion going, and Vadim for
guiding through Cocoon's existing code :-)

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


Mime
View raw message