cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: [c2] XSPUtil.java
Date Thu, 15 Mar 2001 05:21:27 GMT
Forge wrote:
> 
> Hi there,
> 
> Is this a bug:
> 
> The following function returns either the filename if 'filename' is
> absolute, or the path to the directory where cocoon.xconf and WEB-INF
> reside:
> 
> ---------------------
>     public static String relativeFilename(String filename,
> HttpServletRequest request,
>         ServletContext context) throws IOException {
>             File file = new File(filename);
>             if (file.isAbsolute()) {
>                 return filename;
>             }
>             return NetUtils.getPath(context.getResource(filename).toExternalForm
> ());
>     }
> --------------------
> 
> I myself have a htdocs dir which is the home for cocoon and contains
> WEB-INF, cocoon.xconf and sitemap.xmap.

It would help if we knew what you are trying to accomplish, and what kind
of setup you have.  My assumption is that you have some Servlet Container
hooked up to Apache httpd, and that Cocoon is installed in the root context.

This means that you have something like this working:

/path/to/htdocs/sitemap.xmap
/path/to/htdocs/WEB-INF/*
/path/to/htdocs/dlc/*

Cocoon provides a couple of convenience URL protocols for you:
context://dlc/bla.xml
resource://path/inside/a/jar/bla.xml

In Cocoon, all of your paths are relative to the sitemap.xmap file.  If
you want to include a file, then make sure Cocoon can find it using the
Context protocol, or even the relative path will do the same thing.

Your path and the code you presented won't work.

/path/to/htdocs/dlc/source.xml
/path/to/htdocs/dlc/blah.xml

if source.xml is using <util:include-file name="blah.xml"/> then Cocoon
will look at /path/to/htdocs/bla.xml period.  However, if you change
the code to be <util:include-file name="context://dlc/blah.xml"/> then Cocoon
will find it.

The sitemap changes the layout of URI space mapped to file space.  They
are now different views of the resource space.  They can be independently
modified.  In order for Cocoon to know that you are talking about a relative
file instead of a relative URI, you must use the proper method of accessing it.

> 
> I also have a subdirectory 'dlc' in which the following xml file
> resides:
> 
> <snippet>
>   <util:include-file name="bla.xml"/>
> </snippet>
> 
> The errormessage from the exception thrown in the code that is expanded
> from the util:include-file tag, the directory given is
> 
> /path/to/htdocs
> 
> and not even
> 
> /path/to/htdocs/dlc
> 
> or even
> 
> /path/to/htdocs/dlc/bla.xml, which of course does not occur since the file
> exists in that place.
> 
> Can someone please look at this?
> 
> Thanks!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message