You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jeremy Green <jg...@dcom-solutions.com> on 2001/03/13 09:52:13 UTC

Caching with XSP ()

I'm trying to figure out how to get Cocoon to cache an XSP page (Cocoon 
1.8.2).  I've checked all the documentation, and searched through the 
mail archives, and there is not one single example of a working 
configuration that I can find.  From what I can gather it should cache 
the page if I put the <util:cacheable/> tag withing 
<xsp:structure></xsp:structure>, and if I have a hasChanged(Object 
context) method in the page.  I've tried every combination and placement 
of these that I can think of and nothing works. 

Can someone tell me what I'm missing?  Here is the code for a very bare 
bones page (XML/XSP and XSL) that I'm trying to get to cache.  I'm not 
actually using the XSP to do anything useful, I just need to get it to 
cache so I can use a similar technique on some real pages.

I know that the caching mechanism itself is turned on and working 
because if I comment out all the XSP stuff in the page below, the 
straight XML->(XSL)->HTML transformation is cached. 

cache_test.xml
-----------------------------------------
<?xml version="1.0"?>

<?cocoon-process type="xsp"?>   

<?cocoon-process type="xslt"?>
<?xml-stylesheet href="cache_test.xsl" type="text/xsl" ?>

<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"
   xmlns:util="http://www.apache.org/1999/XSP/Util"
 >

<xsp:structure>
               <xsp:cacheable/>   
</xsp:structure>
<xsp:logic>
         public boolean hasChanged (Object context) {
               return false;
         }     
</xsp:logic>

<page>   
  <title>
    Cache test
  </title>

  <bodyContent>
    Here is the body content.
  </bodyContent>
</page>

</xsp:page>

------------------------------------------


cache_test.xsl
------------------------------------------
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/page">

<html>
   <head>
       <title><xsl:apply-templates select="title"/></title>
   </head>
   <body>
       <h1><xsl:value-of select="title"/></h1>
      
       <xsl:apply-templates select="bodyContent"/>
   </body>
</html>

</xsl:template>

</xsl:stylesheet>


-----------------------------------------------

I hope someone can tell me what I'm doing wrong here.  I'd really 
appreciate either some pointers on what I've done wrong, or just some 
sample code of one that works.

Thanks in advance,
Jeremy




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: [C2] New installation problem with Tomcat 4.0b1and JDK 1.3

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
> If you use the latest nightly of Catalina you do not need to rename or
> remove any jars, but you need to add the following to the web.xml for
> cocoon.
>
>     <init-param>
>        <!-- change param value to path to Catalina's servlet.jar -->
>       <param-name>extra-classpath</param-name>
>       <param-value>%CATALINA_HOME%\common\lib\servlet.jar</param-value>
>     </init-param>
>
>
> try this for B1 or go to the nightly.

Thank you for your answer.
This didn't help, but it gave me the idea how to solve this problem: I
simply compied servlet.jar from Catalina into the Cocoons WEB-INF/lib
directory and it worked.

Is that a correct Cocoon param (extra-classpath)? Why didn't it work? Any
suggestions?

So, I can conclude, that to install Cocoon2 with Tomcat 4.0b-1 we will need
to:

1. Remove crimson.jar and maybe jaxp.jar from %CATALINA_HOME%\lib

2. Enable Cocoon to find the servlet.jar either by coping it from Catalina
into Cocoon's WEB-INF\lib or adding additional init-param to Cocoon's
web.xml (it didn't work in my case):
     <init-param>
        <!-- change param value to path to Catalina's servlet.jar -->
       <param-name>extra-classpath</param-name>
       <param-value>%CATALINA_HOME%\common\lib\servlet.jar</param-value>
     </init-param>

Regards,
    Konstantin Piroumian.





---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: [C2] New installation problem with Tomcat 4.0b1and JDK 1.3

Posted by Colin Britton <cb...@centervilletech.com>.
If you use the latest nightly of Catalina you do not need to rename or
remove any jars, but you need to add the following to the web.xml for
cocoon.

    <init-param>
       <!-- change param value to path to Catalina's servlet.jar -->
      <param-name>extra-classpath</param-name>
      <param-value>%CATALINA_HOME%\common\lib\servlet.jar</param-value>
    </init-param>


try this for B1 or go to the nightly.

rgds
CB

----- Original Message -----
From: "Piroumian, Konstantin" <KP...@flagship.ru>
To: <co...@xml.apache.org>
Sent: Tuesday, March 13, 2001 5:00 AM
Subject: [C2] New installation problem with Tomcat 4.0b1and JDK 1.3


> Hi, again!
>
> I solved Cocoon2 installation problem with libraries:
> the jars that had to be removed was: crimson.jar, japx.jar from Tomcat lib
> directory.
>
> Now I get another error: org.apache.cocoon.ProcessingException: The
sitemap
> handler's sitemap is not available.
>
> Can anybody tell me why does this happen?
>
> I learn from Cocoon logs that the sitemap could not be compiled. This is
the
> message:
> ...
> DEBUG   7951    [cocoon  ] (Thread-2): Language Exception
> org.apache.cocoon.components.language.LanguageException: Error compiling
> sitemap_xmap:
> Line 0, column 0:
>
D:\jakarta-tomcat\jakarta-tomcat-4.0-b1\work\localhost\cocoon\org\apache\coc
> oon\www\sitemap_xmap.java:21: Class javax.servlet.http.HttpServletRequest
> not found in import.
> import javax.servlet.http.HttpServletRequest;
> ...
>
> Is this an error somewhere in sitemap.xsl logicsheet?
>
> The other warning from logs is this:
> ...
> WARN    6369    [cocoon  ] (Thread-2): Could not expand
> Directory:D:\JBuilder40\jdk1.3\jre\lib\ext
> org.apache.cocoon.components.language.LanguageException: Attempted to
> retrieve directory listing of non-directory
D:\JBuilder40\jdk1.3\jre\lib\ext
> ...
> D:\JBuilder40\jdk1.3 is my JAVA_HOME environment variable value.
> I have no such a directory etc in %JAVA_HOME%\jre\lib\. What's wrong with
my
> JDK?
>
> My configuration:
> Windows NT 4.0 Sp6
> Tomcat 4.0b-1
> Sun JDK 1.3
> Cocoon2 from the yesterday's CVS snapshot.
>
> Help is very appreciated.
>
> Best regards,
>
> Konstantin Piroumian
> Software engineer
>
> Protek Flagship LLC
> Phone: + 7 095 795 0520 (add. 1288)
> Fax: + 7 095 795 0525
> E-mail: kpiroumian@flagship.ru
> http://www.protek.com
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


[C2] New installation problem with Tomcat 4.0b1and JDK 1.3

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
Hi, again!

I solved Cocoon2 installation problem with libraries:
the jars that had to be removed was: crimson.jar, japx.jar from Tomcat lib
directory.

Now I get another error: org.apache.cocoon.ProcessingException: The sitemap
handler's sitemap is not available.

Can anybody tell me why does this happen?

I learn from Cocoon logs that the sitemap could not be compiled. This is the
message:
...
DEBUG   7951    [cocoon  ] (Thread-2): Language Exception
org.apache.cocoon.components.language.LanguageException: Error compiling
sitemap_xmap:
Line 0, column 0:
D:\jakarta-tomcat\jakarta-tomcat-4.0-b1\work\localhost\cocoon\org\apache\coc
oon\www\sitemap_xmap.java:21: Class javax.servlet.http.HttpServletRequest
not found in import.
import javax.servlet.http.HttpServletRequest;
...

Is this an error somewhere in sitemap.xsl logicsheet?

The other warning from logs is this:
...
WARN    6369    [cocoon  ] (Thread-2): Could not expand
Directory:D:\JBuilder40\jdk1.3\jre\lib\ext
org.apache.cocoon.components.language.LanguageException: Attempted to
retrieve directory listing of non-directory D:\JBuilder40\jdk1.3\jre\lib\ext
...
D:\JBuilder40\jdk1.3 is my JAVA_HOME environment variable value.
I have no such a directory etc in %JAVA_HOME%\jre\lib\. What's wrong with my
JDK?

My configuration:
Windows NT 4.0 Sp6
Tomcat 4.0b-1
Sun JDK 1.3
Cocoon2 from the yesterday's CVS snapshot.

Help is very appreciated.

Best regards,

Konstantin Piroumian
Software engineer

Protek Flagship LLC
Phone: + 7 095 795 0520 (add. 1288)
Fax: + 7 095 795 0525
E-mail: kpiroumian@flagship.ru
http://www.protek.com

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Caching with XSP ()

Posted by "Eric A. Sirois" <ea...@hotmail.com>.
Hello Jeremy,

Your XSP page is still an XML document.  In the XSP page there are references to XML namespaces.  I added xmlns="http://www.foobar.com" to the XML file as a namespace to be able to differentiate <xsp:page> from <page>.  With a default namespace, there is still an implied difference between <xsl:page> and <page>, <page> belongs to and all element, but not attributes to the "http://www.foobar.com" namespace.  If you want attributes to also belong to a specific namesapce, they must preceded by a prefix. .  If you choose not to define a default namesapce, but specific namespace xmlns:test="http://www.foobar.com" , then all elements and attributes that belong to that namespace must be identified with a prefix.

<xsp:page> and <page> are not from same namespace, therefore, they are not the same element.  The stylesheet, and XPath must be able to differentiate between <page> belonging to the xsp namespace and <page> belonging to some other namespace.  In the original stylesheet, you had <xsl:template match="/page">, XPath did not know which element <page> to match.  <xsp:page> did not match and <page> did not exist, since the original XML file did not have a default namespace there is still some prefix <???:page> even though in the document it's <page>, what it is I'm not sure I still have to read the namespace spec again to find out. By adding a namespace,xmlns:test="http://www.foobar.com" , or default namespace, xmlns="http://www.foobar.com" , XPath is able to differentiate between the "page" and XSLT is able to apply to the appropriate template to that element.  

A namespace can be any URI, as long as it is unique.  It does not have to be real or actually pointing to actual XML schema. 

How XSP fits into Cocoon, I'm still not sure?. More reading to do. :-) But, from an XML, XPath, and XSLT POV the files still have to be transformed before they can be cached in Cocoon.  I imagine that what is being cached is still the result of the transform, which, from what you mentioned below should still be an HTML page.  

I tried the XSP example on the Apache web site and processed it. Then I lookend at the source from View - Source in IE 5.5 and the processing time went from 2231ms to 31ms.  Then I view it in Netscape, the first one was 100ms and 31ms for the second.  So it looks like the pages are being cached.  If you look at the example on the Apache website you will see that the author addes the xmlns:example="http://www.plenix.com/DTD/XSP/Example" namespace to the XML and XSL file.

Also remove the DOCTYPE statement in the XSL file it is not valid.  

HTH.  I f you have any other questions let me know.

Regards,

Eric



----- Original Message ----- 
  From: Jeremy Green 
  To: cocoon-users@xml.apache.org 
  Sent: Tuesday, March 13, 2001 10:53 AM
  Subject: Re: Caching with XSP (<util:cacheable/>)


  Eric,

  Thanks for the reply.  Yes, I am trying to display the contents of <page> (or <test:page> in the newest version), not <xsp:page/>.  I just have a few questions.  First is, how/why are you refrencing /xsp:page/test:page in the stylesheet?  Once the XSP page has been processed there is no more xsp:page element to be dealt with.  All I can figure is that you made changes to the cache_test.xml file too, but didn't show the changes in your email.  Secondly, how does any of this namespace stuff affect caching?  My main concern at this point is to get an XML document processed by XSP to include dynamic content, transform the results with XSLT and then have all of the results cached.  I can't really tell that the changes you suggest impact that at all.  Per your recomendations (with some tweaking so that it will actually process) this is what I have for my XML and XSL pages, which still does not get cached.


  cache_test.xml
  -------------------------------------------------------


  <?xml version="1.0"?> 

  <?cocoon-process type="xsp"?>    

  <?cocoon-process type="xslt"?>
  <?xml-stylesheet href="cache.xsl" type="text/xsl" ?>



  <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"
     xmlns:util="http://www.apache.org/1999/XSP/Util"
     xmlns:test="http://www.foobar.com"
  >

  <xsp:structure>
                 <xsp:cacheable/>    
  </xsp:structure>
  <xsp:logic>
           public boolean hasChanged (Object context) {
                 return false;
           }      
  </xsp:logic>


  <test:page>    
    <test:title> 
      Cache test
    </test:title>

    <test:bodyContent>
      Here is the body content.
    </test:bodyContent>
  </test:page> 


  </xsp:page> 
  ---------------------------------------------------------------

  cache_test.xsl
  ---------------------------------------------------------------

  <?xml version="1.0"?>
  <?cocoon-format type="text/html"?>

  <!-- Written by Stefano Mazzocchi "stefano@apache.org" -->
  <!DOCTYPE xsl:stylesheet>               <----remove this is not valid!!


  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"    
    xmlns:test="http://www.foobar.com" version="1.0"
  >



  <xsl:template match="/xsp:page">                   <------ Added this extra template, otherwise, the entire content is dsplayed without HTML tagging
   <xsl:apply-templates select="test:page"/>
  </xsl:template>


  <xsl:template match="test:page">   <---------------------------- removed the xsp:page since we find it the template above.

  <html>

     <head>
         <title><xsl:apply-templates select="test:title"/></title>
     </head>
     <body>
         <h1><xsl:value-of select="test:title"/></h1>
         
         <xsl:apply-templates select="test:bodyContent"/>
     </body>
  </html>

  </xsl:template>

  <xsl:template match="test:bodyContent">
   <xsl:value-of select="."/>
   
  </xsl:template>

  </xsl:stylesheet>
  ----------------------------------------------------------------


  Thanks again,
  Jeremy











  Eric A. Sirois wrote:

Hello,Which page element are you trying to display <xsp:page> or <page>? I'massuming it's the latter. In you XML documents you have two namespaceidntified.  XSLT and XPath are namespace aware.I modified your xsl file, but it's still picking up some of the XSP logic.Here it is.There is still a little bit of cleanup left to do , unless this is what youare looking for.I just added xmlns="http://www.foobar.com" to the namespace of the XML file.You should include your own URI as the default namespace. It does not haveto exist, just something to identify some elements form others, but youstill have to add a prefix to the XSL file.  I'm still trying to figure outif it is possible to do the XPath without the extra prefix.HTH,Eric----------!
---------------------test.html------------------------------- <?xml version="1.0" encoding="utf-8"?>          public boolean hasChanged (Object context) {                return false;          } <html><head><title>     Cache test   </title></head><body><h1>     Cache test   </h1>     Here is the body content.   </body></html>-------------------------------cache_test.xsl------------------------------------<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:xsp="http://www.apache.org/1999/XSP/Core"xmlns:test="http://www.foobar.com" version="1.0!
"> <xsl:template match="/xsp:page/test:page"> <html>    <head>        <title><xsl:apply-templates select="test:title"/></title>    </head>    <body>        <h1><xsl:value-of select="test:title"/></h1>        <xsl:apply-templates select="test:bodyContent"/>    </body> </html> </xsl:template> </xsl:stylesheet>----- Original Message -----From: "Jeremy Green" <jg...@dcom-solutions.com>To: <co...@xml.apache.org>Sent: Tuesday, March 13, 2001 3:52 AMSubject: Caching with XSP (<util:cacheable/>)
I'm trying to figure out how to get Cocoon to cache an XSP page (Cocoon1.8.2).  I've checked all the documentation, and searched through themail archives, and there is not one single example of a workingconfiguration that I can find.  From what I can gather it should cachethe page if I put the <util:cacheable/> tag withing<xsp:structure></xsp:structure>, and if I have a hasChanged(Objectcontext) method in the page.  I've tried every combination and placementof these that I can think of and nothing works.Can someone tell me what I'm missing?  Here is the code for a very barebones page (XML/XSP and XSL) that I'm trying to get to cache.  I'm notactually using the XSP to do anything useful, I just need to get it tocache so I can use a similar technique on some real pages.I know that the caching mechanism itself is turned on and workingbecause if I comment out all th!
e XSP stuff in the page below, thestraight XML->(XSL)->HTML transformation is cached.cache_test.xml-----------------------------------------<?xml version="1.0"?><?cocoon-process type="xsp"?><?cocoon-process type="xslt"?><?xml-stylesheet href="cache_test.xsl" type="text/xsl" ?><xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"   xmlns:util="http://www.apache.org/1999/XSP/Util" ><xsp:structure>               <xsp:cacheable/></xsp:structure><xsp:logic>         public boolean hasChanged (Object context) {               return false;         }</xsp:logic><page>  <title>    Cache test  </title>  <bod!
yContent>    Here is the body content.  </bodyContent></page></xsp:page>------------------------------------------cache_test.xsl------------------------------------------<!DOCTYPE xsl:stylesheet><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/page"><html>   <head>       <title><xsl:apply-templates select="title"/></title>   </head>   <body>       <h1><xsl:value-of select="title"/></h1>       <xsl:apply-templates select="bodyContent"/>   </body></html></xsl:template></xsl:stylesheet>-----------------------------------------------I hope someone can tell me what I'm doing wrong here.  I'd reallyappreciate either some pointers on what I've done wrong, or just somesample code of one that works.Thanks in advance,Jeremy---------------------------------------------------------------------Please check that your question has not already been answered in theFAQ before posting. <http://xml.apache.org/cocoon/faqs.html>To unsubscribe, e-mail: <co...@xml.apache.org>For additional commands, e-mail: <co...@xml.apache.org>
---------------------------------------------------------------------Please check that your question has not already been answered in theFAQ before posting. <http://xml.apache.org/cocoon/faqs.html>To unsubscribe, e-mail: <co...@xml.apache.org>For additional commands, e-mail: <co...@xml.apache.org>



Re: Caching with XSP ()

Posted by Jeremy Green <ja...@wbdn.com>.
Eric,

Thanks for the reply.  Yes, I am trying to display the contents of 
<page> (or <test:page> in the newest version), not <xsp:page/>.  I just 
have a few questions.  First is, how/why are you refrencing 
/xsp:page/test:page in the stylesheet?  Once the XSP page has been 
processed there is no more xsp:page element to be dealt with.  All I can 
figure is that you made changes to the cache_test.xml file too, but 
didn't show the changes in your email.  Secondly, how does any of this 
namespace stuff affect caching?  My main concern at this point is to get 
an XML document processed by XSP to include dynamic content, transform 
the results with XSLT and then have all of the results cached.  I can't 
really tell that the changes you suggest impact that at all.  Per your 
recomendations (with some tweaking so that it will actually process) 
this is what I have for my XML and XSL pages, which still does not get 
cached.


cache_test.xml
-------------------------------------------------------

<?xml version="1.0"?>

<?cocoon-process type="xsp"?>   

<?cocoon-process type="xslt"?>
<?xml-stylesheet href="cache.xsl" type="text/xsl" ?>



<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"
   xmlns:util="http://www.apache.org/1999/XSP/Util"
   xmlns:test="http://www.foobar.com"
 >

<xsp:structure>
               <xsp:cacheable/>   
</xsp:structure>
<xsp:logic>
         public boolean hasChanged (Object context) {
               return false;
         }     
</xsp:logic>


<test:page>   
  <test:title>
    Cache test
  </test:title>

  <test:bodyContent>
    Here is the body content.
  </test:bodyContent>
</test:page>


</xsp:page>
---------------------------------------------------------------

cache_test.xsl
---------------------------------------------------------------

<?xml version="1.0"?>
<?cocoon-format type="text/html"?>

<!-- Written by Stefano Mazzocchi "stefano@apache.org" -->
<!DOCTYPE xsl:stylesheet>


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"   
  xmlns:test="http://www.foobar.com" version="1.0"
 >



<xsl:template match="/test:page">

<html>

   <head>
       <title><xsl:apply-templates select="test:title"/></title>
   </head>
   <body>
       <h1><xsl:value-of select="test:title"/></h1>
      
       <xsl:apply-templates select="test:bodyContent"/>
   </body>
</html>

</xsl:template>

</xsl:stylesheet>

----------------------------------------------------------------


Thanks again,
Jeremy











Eric A. Sirois wrote:

> Hello,
> 
> Which page element are you trying to display <xsp:page> or <page>? I'm
> assuming it's the latter. In you XML documents you have two namespace
> idntified.  XSLT and XPath are namespace aware.
> 
> I modified your xsl file, but it's still picking up some of the XSP logic.
> Here it is.
> There is still a little bit of cleanup left to do , unless this is what you
> are looking for.
> 
> I just added xmlns="http://www.foobar.com" to the namespace of the XML file.
> You should include your own URI as the default namespace. It does not have
> to exist, just something to identify some elements form others, but you
> still have to add a prefix to the XSL file.  I'm still trying to figure out
> if it is possible to do the XPath without the extra prefix.
> 
> HTH,
> 
> Eric
> 
> -------------------------------test.html-------------------------------
> 
>  <?xml version="1.0" encoding="utf-8"?>
> 
>           public boolean hasChanged (Object context) {
>                 return false;
>           }
> 
>  <html><head><title>
>      Cache test
>    </title></head><body><h1>
>      Cache test
>    </h1>
>      Here is the body content.
>    </body></html>
> 
> -------------------------------cache_test.xsl-------------------------------
> -----
> <?xml version="1.0" encoding="UTF-8"?>
>  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core"
> xmlns:test="http://www.foobar.com" version="1.0">
> 
>  <xsl:template match="/xsp:page/test:page">
> 
>  <html>
>     <head>
>         <title><xsl:apply-templates select="test:title"/></title>
>     </head>
>     <body>
>         <h1><xsl:value-of select="test:title"/></h1>
> 
>         <xsl:apply-templates select="test:bodyContent"/>
>     </body>
>  </html>
> 
>  </xsl:template>
> 
>  </xsl:stylesheet>
> 
> 
> 
> 
> 
> ----- Original Message -----
> From: "Jeremy Green" <jg...@dcom-solutions.com>
> To: <co...@xml.apache.org>
> Sent: Tuesday, March 13, 2001 3:52 AM
> Subject: Caching with XSP (<util:cacheable/>)
> 
> 
>> I'm trying to figure out how to get Cocoon to cache an XSP page (Cocoon
>> 1.8.2).  I've checked all the documentation, and searched through the
>> mail archives, and there is not one single example of a working
>> configuration that I can find.  From what I can gather it should cache
>> the page if I put the <util:cacheable/> tag withing
>> <xsp:structure></xsp:structure>, and if I have a hasChanged(Object
>> context) method in the page.  I've tried every combination and placement
>> of these that I can think of and nothing works.
>> 
>> Can someone tell me what I'm missing?  Here is the code for a very bare
>> bones page (XML/XSP and XSL) that I'm trying to get to cache.  I'm not
>> actually using the XSP to do anything useful, I just need to get it to
>> cache so I can use a similar technique on some real pages.
>> 
>> I know that the caching mechanism itself is turned on and working
>> because if I comment out all the XSP stuff in the page below, the
>> straight XML->(XSL)->HTML transformation is cached.
>> 
>> cache_test.xml
>> -----------------------------------------
>> <?xml version="1.0"?>
>> 
>> <?cocoon-process type="xsp"?>
>> 
>> <?cocoon-process type="xslt"?>
>> <?xml-stylesheet href="cache_test.xsl" type="text/xsl" ?>
>> 
>> <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>>    xmlns:util="http://www.apache.org/1999/XSP/Util"
>>  >
>> 
>> <xsp:structure>
>>                <xsp:cacheable/>
>> </xsp:structure>
>> <xsp:logic>
>>          public boolean hasChanged (Object context) {
>>                return false;
>>          }
>> </xsp:logic>
>> 
>> <page>
>>   <title>
>>     Cache test
>>   </title>
>> 
>>   <bodyContent>
>>     Here is the body content.
>>   </bodyContent>
>> </page>
>> 
>> </xsp:page>
>> 
>> ------------------------------------------
>> 
>> 
>> cache_test.xsl
>> ------------------------------------------
>> <!DOCTYPE xsl:stylesheet>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>> 
>> <xsl:template match="/page">
>> 
>> <html>
>>    <head>
>>        <title><xsl:apply-templates select="title"/></title>
>>    </head>
>>    <body>
>>        <h1><xsl:value-of select="title"/></h1>
>> 
>>        <xsl:apply-templates select="bodyContent"/>
>>    </body>
>> </html>
>> 
>> </xsl:template>
>> 
>> </xsl:stylesheet>
>> 
>> 
>> -----------------------------------------------
>> 
>> I hope someone can tell me what I'm doing wrong here.  I'd really
>> appreciate either some pointers on what I've done wrong, or just some
>> sample code of one that works.
>> 
>> Thanks in advance,
>> Jeremy
>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> Please check that your question has not already been answered in the
>> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>> 
>> To unsubscribe, e-mail: <co...@xml.apache.org>
>> For additional commands, e-mail: <co...@xml.apache.org>
>> 
>> 
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
> 
> 


Re: Caching with XSP ()

Posted by "Eric A. Sirois" <ea...@hotmail.com>.
Hello,

Which page element are you trying to display <xsp:page> or <page>? I'm
assuming it's the latter. In you XML documents you have two namespace
idntified.  XSLT and XPath are namespace aware.

I modified your xsl file, but it's still picking up some of the XSP logic.
Here it is.
There is still a little bit of cleanup left to do , unless this is what you
are looking for.

I just added xmlns="http://www.foobar.com" to the namespace of the XML file.
You should include your own URI as the default namespace. It does not have
to exist, just something to identify some elements form others, but you
still have to add a prefix to the XSL file.  I'm still trying to figure out
if it is possible to do the XPath without the extra prefix.

HTH,

Eric

-------------------------------test.html-------------------------------

 <?xml version="1.0" encoding="utf-8"?>

          public boolean hasChanged (Object context) {
                return false;
          }

 <html><head><title>
     Cache test
   </title></head><body><h1>
     Cache test
   </h1>
     Here is the body content.
   </body></html>

-------------------------------cache_test.xsl-------------------------------
-----
<?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:test="http://www.foobar.com" version="1.0">

 <xsl:template match="/xsp:page/test:page">

 <html>
    <head>
        <title><xsl:apply-templates select="test:title"/></title>
    </head>
    <body>
        <h1><xsl:value-of select="test:title"/></h1>

        <xsl:apply-templates select="test:bodyContent"/>
    </body>
 </html>

 </xsl:template>

 </xsl:stylesheet>





----- Original Message -----
From: "Jeremy Green" <jg...@dcom-solutions.com>
To: <co...@xml.apache.org>
Sent: Tuesday, March 13, 2001 3:52 AM
Subject: Caching with XSP (<util:cacheable/>)


> I'm trying to figure out how to get Cocoon to cache an XSP page (Cocoon
> 1.8.2).  I've checked all the documentation, and searched through the
> mail archives, and there is not one single example of a working
> configuration that I can find.  From what I can gather it should cache
> the page if I put the <util:cacheable/> tag withing
> <xsp:structure></xsp:structure>, and if I have a hasChanged(Object
> context) method in the page.  I've tried every combination and placement
> of these that I can think of and nothing works.
>
> Can someone tell me what I'm missing?  Here is the code for a very bare
> bones page (XML/XSP and XSL) that I'm trying to get to cache.  I'm not
> actually using the XSP to do anything useful, I just need to get it to
> cache so I can use a similar technique on some real pages.
>
> I know that the caching mechanism itself is turned on and working
> because if I comment out all the XSP stuff in the page below, the
> straight XML->(XSL)->HTML transformation is cached.
>
> cache_test.xml
> -----------------------------------------
> <?xml version="1.0"?>
>
> <?cocoon-process type="xsp"?>
>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="cache_test.xsl" type="text/xsl" ?>
>
> <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>    xmlns:util="http://www.apache.org/1999/XSP/Util"
>  >
>
> <xsp:structure>
>                <xsp:cacheable/>
> </xsp:structure>
> <xsp:logic>
>          public boolean hasChanged (Object context) {
>                return false;
>          }
> </xsp:logic>
>
> <page>
>   <title>
>     Cache test
>   </title>
>
>   <bodyContent>
>     Here is the body content.
>   </bodyContent>
> </page>
>
> </xsp:page>
>
> ------------------------------------------
>
>
> cache_test.xsl
> ------------------------------------------
> <!DOCTYPE xsl:stylesheet>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="/page">
>
> <html>
>    <head>
>        <title><xsl:apply-templates select="title"/></title>
>    </head>
>    <body>
>        <h1><xsl:value-of select="title"/></h1>
>
>        <xsl:apply-templates select="bodyContent"/>
>    </body>
> </html>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> -----------------------------------------------
>
> I hope someone can tell me what I'm doing wrong here.  I'd really
> appreciate either some pointers on what I've done wrong, or just some
> sample code of one that works.
>
> Thanks in advance,
> Jeremy
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>