cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Green <...@wbdn.com>
Subject Re: Caching with XSP (<util:cacheable/>)
Date Tue, 13 Mar 2001 15:53:06 GMT
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" <jgreen@dcom-solutions.com>
> To: <cocoon-users@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: <cocoon-users-unsubscribe@xml.apache.org>
>> For additional commands, e-mail: <cocoon-users-help@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: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> 
> 


Mime
View raw message