Hi,
I am using old Cocoon 2.0.5-dev and have problem with XSP caching in
following sitemap (some code of sitemap.xmap is intentionally
omitted):
<map:match pattern="getdata">
<map:generate type="serverpages" src="context://path/getdata.xsp"/>
<map:serialize type="xml"/>
</map:match>
<!-- some other things -->
<map:match pattern="site.xml">
<map:aggregate element="Page">
<map:part src="cocoon:/getdata"/>
<!-- other parts -->
</map:aggregate>
<map:transform src="context://path/prepare.xsl"/>
<map:transform type="cinclude"/>
<map:transform type="saxon" src="path/stylesheet.xsl"/>
<map:serialize type="xhtmlt"/>
</map:match>
In path/getdata.xsp there is Java code like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
xmlns:util="http://apache.org/xsp/util/2.0">
<xsp:structure>
<!-- some xsp includes -->
</xsp:structure>
<xsp:logic>
public HashMap getData() { /* getting data from DB and
HttpURLConnection */ }
public long generateKey() {
HashMap a = getData();
String source = "" + a.get("first").toString() +
a.get("second").toString(); // unique
return HashUtil.hash(source); // org.apache.cocoon.util.HashUtil
}
public CacheValidity generateValidity() {
return new DeltaTimeCacheValidity(60); // 60 minutes of validity
}
</xsp:logic>
<Data>
<xsp:logic>
HashMap a = getData();
<!-- there is some Java + XSP code that makes output XML -->
</xsp:logic>
</Data>
</xsp:page>
Later there is path/prepare.xsl which looks:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cinclude="http://apache.org/cocoon/include/1.0">
<xsl:template match="Page">
<Page>
<xsl:copy-of select="Data"/>
<!-- just copy all elements from XSP output -->
<cinclude:include src="properties.xml"/> <!--
other included XML -->
</Page>
</xsl:template>
</xsl:stylesheet>
I wrote this XSL much simplier than it looks in reality (much more logic)
And there is path/stylesheet.xsl transformed by Saxon XSLT processor:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="Page">
<html><body><div><xsl:value-of select="."/></div></body></html>
</xsl:template>
</xsl:stylesheet>
Saxon is defined in global sitemap.xmap by:
<map:transformer logger="sitemap.transformer.saxon" name="saxon"
pool-grow="2" pool-max="32" pool-min="8"
src="org.apache.cocoon.transformation.TraxTransformer">
<use-request-parameters>true</use-request-parameters>
<use-browser-capabilities-db>false</use-browser-capabilities-db>
<use-deli>false</use-deli>
<xslt-processor-role>org.apache.cocoon.components.xslt.XSLTProcessor/saxon</xslt-processor-role>
</map:transformer>
What I want is just 60 minute cache for XSPs, but it works fine only
for about 5 minutes and then cache is "stangely interrupted"
(refreshing other site make invalidity of cache to other site (sites
has variety GET parameters)). But if I change sitemap to (without
path/prepare.xsl and cinclude transformer)
<map:match pattern="site.xml">
<map:aggregate element="Page">
<map:part src="cocoon:/getdata"/>
<!-- other parts -->
</map:aggregate>
<map:transform type="saxon" src="path/stylesheet.xsl"/>
<map:serialize type="xhtmlt"/>
</map:match>
then it works ok. But I have to use cinclude and don't know what I am
doing wrong. Thanks for any help or explanations.
Regards,
Greg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
|