well, after getting a little bit smarter and digging in the code of
Cocoon (from Cocoon CVS), I managed to find a different solution to this
problem. This goes together with the problem of "major bug in XSP" post
and solves both of them.
Referring to the "major bug in XSP" post, I decided to emulate the
offline mode for cocoon. So now I throw a NPE in
JetspeedServletRequest.getContextPath() that is caught in Cocoon.
The possible problem of this being a hack is not so relevant as the
entire Cocoon1 is a little hack and when we move to cocoon2 we'll have
to rework Jetspeed anyway.
What concerns the bug with filename resolving within XML/XSP files, then
it seems to be a bug in the Cocoon version that is distributed together
with Jetspeed. To get access to the source code of Cocoon, I replaced
this with CVS version of cocoon and works just fine...
How about updating cocoon.jar that comes together with Jetspeed?
Neeme
so here is the diff (no need to change the CocoonRenderer.java, should
just update cocoon.jar):
Index: JetspeedServletRequest.java
===================================================================
RCS file:
/products/cvs/jetspeed/jetspeed/src/java/org/apache/jetspeed/util/servle
t/JetspeedServletRequest.java,v
retrieving revision 1.4
diff -r1.4 JetspeedServletRequest.java
107c107,109
< return req.getContextPath();
---
> // possible cause for bugs:
> // this emulates the offline mode for Cocoon
> throw new NullPointerException();
> -----Original Message-----
> From: Neeme Praks
> Sent: Wednesday, June 07, 2000 4:28 PM
> To: JetSpeed (E-mail)
> Subject: [patch] fix the filename resolving within XML/XSP files
>
> Got everything working finally... Now XSP is transformed with
> logicsheet, the result is compiled and the resulting XML is
> transformed
> to HTML using style template. Nice.
>
> The problem was that file.getCanonicalPath() in
> CocoonRenderer.transform() returned the path of the file, not the path
> of the directory the file was in. I changed it into
> file.getParentFile().getCanonicalPath() + "/".
>
> There are still issues, though:
> Paths that are relative to the current document are resolved
> correctly,
> the path is simply added to the path of the original file requested.
> However, when you reference a stylesheet relative to the virtual root
> and jetspeed is running under separate context, then the
> mapping fails.
> Examples:
> 1.
> XML file, physical path: webapps/jetspeed/test.xml
> XML file, virtual path: /jetspeed/test.xml
> stylesheet reference: myStyle.xsl
> resolved correctly: webapps/jetspeed/myStyle.xsl
> 2.
> XML file, physical path: webapps/jetspeed/test.xml
> XML file, virtual path: /jetspeed/test.xml
> stylesheet reference: /otherdir/myStyle.xsl
> resolved incorrectly: webapps/jetspeed/otherdir/myStyle.xsl
>
> The filename mapping in Cocoon 1.* is also a hack, so we
> probably cannot
> get it working properly before Cocoon 2.
> The current solution is working, as long as you don't try to reference
> your stylesheets absolute to the virtual root of your site while
> jetspeed itself is running in separate context under the root.
> If jetspeed would be running in root context, everything could work...
> not sure, though. Someone needs to test this.
>
> The diff is together with the other patch that I submitted
> earlier... is
> it the same file so I don't know which file should I take as
> basis, the
> original or patched...
>
> Neeme
>
> Index: CocoonRenderer.java
> ===================================================================
> RCS file:
> /products/cvs/jetspeed/jetspeed/src/java/org/apache/jetspeed/p
> ortal/coco
> on/CocoonRenderer.java,v
> retrieving revision 1.21
> diff -r1.21 CocoonRenderer.java
> 113c113
> < String stylesheet_pi = "<?xml-stylesheet href=\"" +
> stylesheet
> + "\" type=\"text/xsl\"?>";
> ---
> > boolean stripExistingPIs = (stylesheet != null);
> 115c115
> < SAXPIFilter filter = new SAXPIFilter( new PrintWriter(bos),
> true );
> ---
> > SAXPIFilter filter = new SAXPIFilter( new PrintWriter(bos),
> stripExistingPIs );
> 121c121
> < String fileName = file.getCanonicalPath();
> ---
> > String fileName = file.getParentFile().getCanonicalPath() +
> "/";
> 134c134,138
> < pis.append( stylesheet_pi + "\n");
> ---
> > if (stylesheet != null)
> > {
> > String stylesheet_pi = "<?xml-stylesheet href=\"" +
> stylesheet + "\" type=\"text/xsl\"?>";
> > pis.append( stylesheet_pi + "\n");
> > }
>
>
>
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Archives and Other: <http://java.apache.org/main/mail.html>
> Problems?: [EMAIL PROTECTED]
>
>
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]