You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Fabien Campagne <ca...@inka.mssm.edu> on 2000/03/01 19:14:39 UTC

Re: XSP problem/Cocoon1.7/tag-libs, how to..

Joseph, I confirm your results with cocoon 1.7. 

I several other elements of informations. They helped me
solve the problem with Cocoon 1.7. Here they are.

- Stefano Mazzocchi confimed to me that XSP has a problem
in cocoon 1.7, which has now been fixed in CVS (supposedly
packaged with the 1.7.1 to be).


- Peter Moravek sent me his solution to the problem. I add some of my
  observations to his material below:

With cocoon 1.7:
 1/ use xalan_0_19_3D03.jar,
 2/ make a directory where to hold the tag libraries, for instance /usr/local/cocoon/taglibs
    put the XSP part of your style sheets there. (see below for an example).
 3/ add this directory to the JServ engine classpath
 4/ use the resource:/ way to point to the XSP .xsl file.
    eg processor.xsp.library.example.java = resource://samplelib.xsl
 5/ restart the jserv engine that serves cocoon (you need to restart after each
    modification you make to a library: serious restriction at development time
    in my opinion)
 6/ touch sample.xml (the source) or clean the repository (there is a cache problem:
    the page is not recompiled when a library changes, even when you kill and restart
    the cocoon jserv engine! Now that's really not intuitive..).

 7/ access sample.xml


When you develop, you need to go through steps 5-7 each time you make a change to the 
library. Great fun!

Well, at least this is a work-around. I wonder if these cache problems will be solved in
cocoon 1.7.1.

Fabien Campagne

Fabien Campagne      -- Dept. of Physiology and Biophysics,   
phone: (212)-241-0860   Box 1218, Mount Sinai School of Medicine,
fax:   (212)-860-3369   One Gustave L. Levy Place,
---------------------   New York, NY 10029-6574 -----------------

sample.xml --------------------------------------------- 
<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
 <?xml-stylesheet href="sample.xsl" type="text/xsl"?>

   <xsp:page
    language="java"
      xmlns:xsp="http://www.apache.org/1999/XSP/Core"
          xmlns:example="http://www.plenix.com/DTD/XSP/Example"
   >
       <page title="Time of Day">
           <p>
      To the best of my knowledge, it's now
          <!-- Substitute time of day here -->
        <sample:time-of-day format="yy/MM/dd hh:mm:ss aa"/>
       </p>
</page>
</xsp:page>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

sample.xsl --------------------------------------------
<?xml version="1.0"?>
                                  <xsl:stylesheet
                                    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
                                    xmlns:xsp="http://www.apache.org/1999/XSP/Core"
                                    xmlns:example="http://www.plenix.com/DTD/XSP/Example"

                                  >
<xsl:template match="page">
<html><header/><body><xsl:apply-templates/></body></html>
</xsl:template>
                                  </xsl:stylesheet>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

samplelib.xsl in /usr/local/cocoon/taglibs -----------------------
<?xml version="1.0"?>
<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
     xmlns:xsp="http://www.apache.org/1999/XSP/Core"
     xmlns:example="http://www.plenix.com/DTD/XSP/Example"

   >
<xsl:template match="xsp:page">
   <xsp:page>
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
        </xsl:copy>
	<xsp:structure>
		<xsp:include>java.util.Date</xsp:include>
		<xsp:include>java.text.SimpleDateFormat</xsp:include>
	</xsp:structure>
<xsp:logic>
                                          /* "Example" Class Level Logic */
                                          private static String formatDate(Date date, String pattern) {
                                            if (pattern == null || pattern.length() == 0) {
                                              pattern = "yyyy/MM/dd hh:mm:ss aa";
                                            }
                                            return ("date: " + (new SimpleDateFormat(pattern)).format(date));
                                          }
</xsp:logic>
  <xsl:apply-templates/>
</xsp:page>
</xsl:template>

<xsl:template match="time-of-day">
<xsp:expr>
   formatDate(new Date(), "<xsl:value-of select="@format"/>")
</xsp:expr>
</xsl:template>

<xsl:template match="@*|node()" priority="-1">
<xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
</xsl:template>

</xsl:stylesheet>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

"Joseph B. Ottinger" wrote:
> 
> On Wed, 1 Mar 2000, James & Sue Ann Birchfield wrote:
> 
> > That would help, huh? :)
> >
> > Let's see.
> >
> > I added thiks to my cocoon.properties:
> > processor.xsp.library.mail.java = file:/usr/local/apache/xsp/mail.xsl
> >
> > And I added the taglib class files to my servlet classpath.
> >
> > I believe that is all I had to change.
> > Let me know if that works for you, and if
> > not, I will investigate further(Sorry, it
> > has been a while since I have been able to look
> > at the cocoon stuff)
> 
> I tried this as a variation, as well as just
> /home/joeo/public_html/fusion2.xsl (the full path), and various
> combinations of valid and invalid URIs, including the one you're
> using. Using just the path (no protocol) didn't throw a
> FileNotFoundException, but it didn't work.
> 
> Using file:/home... threw the filenotfound exception.
> 
> Using the full proper URI (file:///home/joeo...) threw the file not found
> exception.
> 
> using file://home/joeo... had the same effect. Only by not using the
> protocol at ALL did I not get the file not found exception, but that also
> did nothing (it didn't apply the stylesheet.)
> 
> Using an HTTP protocol (i.e.,
> processor.xsp.library.fusion2.java=http://cupid.suninternet.com/~joeo/fusion2.xsl
> was the line in cocoon.properties) ALSO threw a file not found exception,
> which I rather expected. :)
> 
> I suppose that by now, it's safe to say that cocoon.properties' internal
> notes are incorrect - it's not using a URL to the file. (I've verified the
> path is correct.) It's fully possible my XSL file isn't correct, of
> course, but that shouldn't be causing these problems.
> 
> -----------------------------------------------------------
> Joseph B. Ottinger               joeo@cupid.suninternet.com
> http://cupid.suninternet.com/~joeo      HOMES.COM Developer
> PGP Key is : http://cupid.suninternet.com/~joeo/cherem_pgpk