cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <>
Subject Re: source resolving help
Date Sun, 18 May 2003 22:11:51 GMT
Geoff Howard wrote:

>Source resolving in cocoon is pretty opaque to me - complicated 
>by the fact that the API docs aren't included at excalibur's site.  
>I've tried tracking this down through the source, but I'm never 
>confident that I've found the current best practice and not a 
>deprecated area.  If there's a great example of how to do this, 
>or message from the archives feel free to point me there instead 
>but I haven't found anything clear for a source meant to be a 
>_destination_ as outlined below.
>Here's my situation: in a sitemap component (a file upload handler  
>which will move a PartOnDisk, or write out the stream of a 
>FileInMemory), I want to: 
>1) resolve a directory path relative to the current sitemap, 
>2) create a file in that directory, 
>3) write to the file one time, and close/release it as necessary.
>so, I could do (?) 
>FileSource fs = (FileSource)resolver.resolveURI("directory/filename.ext");


>Then I guess I could do 
>orignalFile.renameTo(fs.getSystemId()) or

originalFile.renameTo(fs.getFile) would be better.

>fs.getOutputStream() ??

This what you'd like to do if you want to _copy_ the file, or fill the 
target file with some data that doesn't come from another file.

>- Have I understood all this correctly?
Nearly ;-)

>- What are the hidden gotchas?  
You may look at ModifiableSource and SourceUtil.copy/move that give some 
higher abstraction.

>- Do I need file:/directory/filename.ext ??
For the source or the destination ?

>- Can I use relative or absolute paths? (eg ../../directory or /var ) with this scheme?
The SourceResolver considers relative paths as starting from the current 
sitemap's directory. And you should be able to use ../.. if needed.

Hope this helps,


Sylvain Wallez                                  Anyware Technologies 
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }

View raw message